Why unused namespace defined in xaml file breaks generation of protobuf files? - grpc-c#

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?

Related

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).

Install OpenCV-2.4.9 on CentOS 7 (PC)

I'm trying to install OpenCV-2.4.9 on CentOS 7 (PC) however getting error after 16% when running "make" command. I leave default configuration for OpenCV.
make
...
[ 16%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_v4l.cpp.o /opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp:306:29: error: field ‘capability’ has incomplete type
struct video_capability capability;
^ /opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp:307:29: error: field ‘captureWindow’ has incomplete type
struct video_window captureWindow;
....
....
/opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp: In function ‘void icvCloseCAM_V4L(CvCaptureCAM_V4L*)’:
/opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp:2812:46: error: ‘CvCaptureCAM_V4L’ has no member named ‘memoryBuffer’
It seems that the define HAVE_CAMV4L has the value 1, if you look in the file modules/highgui/src/cap_v4l.cpp looking for the structure definition at the row 306. If the compilation fails at that point this means that the video4linux development configuration is corrupted.
Using google I have found that the OpenCV Bug #1357 is described as follow:
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L) succeeds even though linux/videodev.h doesn't exist on the system. (Bug #1357)
http://code.opencv.org/issues/1357
Anyway the solution is described at the same URL for "HAVE_CAMV4L gets set incorrectly": "Setting it to FALSE in CMakeLists.txt fixes the problem".

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.

How to get answer from messagebox

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.

Resources