How to get answer from messagebox - visual-c++

I copy
if ((MessageBox::Show(
"Are you sure that you would like to close the form?",
"Form Closing", MessageBoxButtons::YesNo,
MessageBoxIcon::Question) == DialogResult::No))
{
// cancel the closure of the form.
Application::Exit();
}
From msdn. Where I compiling this i have
1>------ Build started: Project: test2, Configuration: Debug Win32 ------
1> test2.cpp
1>c:\users\kredkołamacz\documents\visual studio 2010\projects\test2\test2\Form1.h(103): error C2039: 'No' : is not a member of 'System::Windows::Forms::Form::DialogResult'
1> c:\users\kredkołamacz\documents\visual studio 2010\projects\test2\test2\Form1.h(16) : see declaration of 'System::Windows::Forms::Form::DialogResult'
1>c:\users\kredkołamacz\documents\visual studio 2010\projects\test2\test2\Form1.h(103): error C2065: 'No' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What's wrong? How fix this problem?

I’m stumped but the MSDN article for DialogResult mentions in the C++ example that the type name should be prefixed with :: to make it non-nested. Maybe try this:
if (MessageBox::Show(
"Are you sure that you would like to close the form?",
"Form Closing", MessageBoxButtons::YesNo,
MessageBoxIcon::Question) == ::DialogResult::No)
(I also removed the redundant parentheses …)
If it doesn’t help, try specifying the full namespace, i.e. ::System::Windows::Forms::DialogResult::No to see if that at least works.

Related

Why unused namespace defined in xaml file breaks generation of protobuf files?

i have simple WPF project to demonstrate my issue
this is my build log
Rebuild started...
1>------ Rebuild All started: Project: WpfApp, Configuration: Debug Any CPU ------
Restored d:\projects\GrpcError\WpfApp\WpfApp.csproj (in 6 ms).
1>d:\projects\GrpcError\WpfApp\MainWindow.xaml.cs(2,14,2,20): error CS0234: The type or namespace name 'Protos' does not exist in the namespace 'WpfApp' (are you missing an assembly reference?)
1>Done building project "WpfApp_khdt0wpw_wpftmp.csproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
funny part is that visual studio (2022) correctly navigates to generated file (d:\projects\GrpcError\WpfApp\obj\Debug\net6.0-windows\Protos\Login.cs) with namespace WpfApp.Protos.Core defined ...
i managed to track this error to MainWindow.xaml file -
compilation will be successfull if i remove this line: xmlns:local="clr-namespace:WpfApp"
any idea why is this happening?

Error in Xamarin.iOS build: Given path's format is not supported

In an iOS project in Visual Studio 2015, networked to a Mac, I get this error on build...
C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(411,3): error : The given path's format is not supported.
The same solution copied to the Mac builds and runs OK in Visual Studio for Mac preview.
Xamarin.iOS.Common.targets, at line 411 position 3 is this:
<SmartCopy
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
SourceFiles = "#(_BundleResourceWithOutputPath)"
DestinationFiles = "#(_BundleResourceWithOutputPath -> '%(OutputPath)')"
/>
Question: Ids there any way tosee what these tokens resolve to at build-time?
Note: Here is the build output that fails...
. . .
1> Copying file from '/Users/user123483/Library/Caches/Xamarin/mtbs/builds/TrySpeechPlus/d33d40e519762246de1faff7c177fd44/obj/iPhoneSimulator/Debug/optimized/Images/whtball2.PNG' to '/Users/user123483/Library/Caches/Xamarin/mtbs/builds/TrySpeechPlus/d33d40e519762246de1faff7c177fd44/bin/iPhoneSimulator/Debug/TrySpeechPlus.app/Images/whtball2.PNG'
1> SmartCopy: 2017-02-11T10:05:56.0785600-05:00 - Deserializing outputs
1> SmartCopy: 2017-02-11T10:05:56.0805590-05:00 - Creating output items
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(411,3): error : The given path's format is not supported.
1> SmartCopy: 2017-02-11T10:05:56.1110734-05:00 - Finished
1>Done executing task "SmartCopy" -- FAILED.
1>Done building target "_CopyResourcesToBundle" in project "TrySpeechPlus.csproj" -- FAILED.
1>
1>Build FAILED.
Can anyone suggest what the problem might be?
The error is caused by the space in the filename (Program Files (x86)).
A fix is to replace the space with the correct escape string
Replace(" ","%20")

MSBuild error MSB4018 in VS2015: The "Link" task failed unexpectedly

After upgrading a solution with 25 projects from VS2012 Update 4 to VS2015 RTM (14.0.23107.0), I get the following error while building one of the projects:
(...) MSB4018: 'The "Link" task failed unexpectedly. (...) System.NullReferenceException: Object reference not set to an instance of an object.' (...)
Here the full output:
1>------ Build started: Project: Buttons, Configuration: Release Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: The "Link" task failed unexpectedly.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: at Microsoft.Build.CPPTasks.Link.ForcedRebuildRequired()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.ComputeOutOfDateSources()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.SkipTaskExecution()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: at Microsoft.Build.Utilities.ToolTask.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__1.MoveNext()
========== Build: 0 succeeded, 1 failed, 24 up-to-date, 0 skipped ==========
I've tried already several suggested solutions related to MSB4018 without any success. The error 'The "Link" task failed unexpectedly' wasn't even indexed by Google yet. I guess this issue is somehow related to the type of the project because it's the only project in the solution that's used as a resource DLL (i.e. with no entry point, etc.). The only changes that have been made to the project file by VS2015 are "ToolsVersion: 4.0 => 14.0" and "PlatformToolset: v110_xp => v140_xp".
Does anyone has a solution for this?
I've managed to fix this issue myself and would like to document the solution here for future reference.
The following error was caused by an empty XML element in the project file:
MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
The empty element was accessed by the 'Link' task, which just failed:
MSB4018: 'The "Link" task failed unexpectedly.
Removing the respective element fixed the issue:
<Link><GenerateDebugInformation></GenerateDebugInformation></Link>
Hint: As it can be seen in other posts, many of the MSB4018 errors seem to be related to project files containing unexpected values.
Another solution is to delete all generated files from the last build through an explorer window.
Delete all files in:
.\Project\bin
.\Project\obj
While you can "Clean" or "Rebuild" directly through Visual Studio, this only captures some of the files. By forcing to recompile all files, all memory locations will now correctly align and the issue should be resolved.
VS 2015: Solution of the problem is as follows:
Goto:
Project Properties->Linker->Debugging->Generate Debug Info,
Set this property either as Optimize for debugging (/DEBUG) or No
Note: I observed similar issue when it was blank(not set).
It worked for me.
Hope this information would be helpful.
Good Luck:).
If the error statement is something like 'System.InvalidCastException: Unable to cast object of type 'System.Xml.XmlComment' to type 'System.Xml.XmlElement'' then you can try the following:
Unload the .csproj file and check for Project ToolsVersion. Make sure that projects ToolsVersion is lesser than 14 (for example 12).

header file error in visual c++

I am newbie in visual c++.i have created a small program,but its showing error C1083.
My program is like this:
#include <iostream.h>
using namespace std;
void main()
{
cout <<"Welcome to cpp program";
}
the error report is :
1>------ Build started: Project: payroll, Configuration: Debug Win32 ------
1> first_page.cpp
1>c:\users\naga\documents\visual studio 2010\projects\payroll\payroll\first_page.cpp(1):
fatal error C1083:
Cannot open include file: 'iostream.h': No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
i have seen that i should do something with the properties.But i didnt understand that stuff.Also When i click the toolbar and property window,no item appears inside them.I doubt this comes coz i have selected win 32 console application???
std include headers do not need the .h
#include <iostream>
should work.

File not compiling due to syntax error on ';' (semi-colon) [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
My Visual Studio 2010 does not allow my file to be compiled when I use the semi-colon characters (";")/ It says there is an error.
But not all of the semi-colons, just one of them.
1>------ Build started: Project: waynekwa, Configuration: Debug Win32 ------
1>Build started 7/11/2012 11:58:46 PM.
1>InitializeBuildStatus:
1> Touching "Debug\waynekwa.unsuccessfulbuild".
1>ClCompile:
1> waynekwa.cpp
1>c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(6): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(304) : see declaration of 'scanf'
1>c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(11): error C2059: syntax error : ';'
1>c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(11): error C2143: syntax error : missing ';' before ')'
1>c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(11): error C2143: syntax error : missing ';' before ')'
1>c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(12): error C2143: syntax error : missing ';' before '{'
1>c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(27): fatal error C1075: end of file found before the left brace '{' at
'c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(3)' was matched
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.14
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The code:
#include<stdio.h>
int main(void) {
int num,x,y=0;
printf("enter range:");
scanf("%i",&num);
for(x=1;x<=;x++) {
if(num%x==0) {
y++;
}
if(y==2) {
printf("it is prime number.\n");
} else {
printf("it is not prime number.\n");
}
return 0;
}
It looks like you forgot a closing bracket for your for loop. You need one between the else of the second if and your return. This is the cause of the second actual error, fatal error C1075: end of file found before the left brace '{'.
Also, for (x = 1; x <= ; x++) is not a valid for loop. The second part x <= ; is missing a value to compare against. For example, x <= 10;. That's where the syntax error error C2059: syntax error : ';' is coming from. The other complaints about semicolons are due to this error.
Edit:
Also, your assignment int num,x,y=0; is difficult to understand. I recommend you clean it up, either by putting on multiple lines or by chain assigning.
Given the information you have given us, you probably need to add or remove one or more ; then add a } somewhere after line 3. But you also may not need to do these things.
The first thing that comes to mind is the line:
for(x=1;x<=;x++) {
you have a x<= just sitting there alone, you have to put a value there.
I'm guessing that you meant:
for(x=1; x<=num; x++) {
But other than that, no other syntax errors are jumping out at me.

Resources