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).
Related
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?
I tried to a create new project through Google maps activity but my android studio keeps through an exception whenever I try build the gradle. Please any solution colleagues. PC... haven't written any code yet.
Here is the gradle message ....
Error:error: resource android:attr/fontVariationSettings not found.
Error:error: resource android:attr/ttcIndex not found.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
I frequently get a crash in testflight builds. Below log is reported in crashlytics for the crash:
Fatal error: Unresolved error
Error Domain=NSCocoaErrorDomain Code=256
"The file ####.sqlite” couldn’t be opened."
UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/D73975F3-ED76-4C7B-A30A-0C751C8471AA/Library/Application Support/####.sqlite, NSSQLiteErrorDomain=23},
["NSFilePath": /var/mobile/Containers/Data/Application/D73975F3-ED76-4C7B-A30A-0C751C8471AA/Library/Application Support/####.sqlite, "NSSQLiteErrorDomain": 23]:
file /Users/elanarulaj/Desktop/voxer_client/packages/sdk.swift/VoxerKit/VoxerKit/Classes/####SDK.swift, line 86
I do not find any working solution in StackOverFlow
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")
Whenever I compile any project on visual studio it fails with the following errors:
2>CSC : error CS1583:
'$path\obj\Debug\CSC1DCAF528D2BE4F9F8084DAE56ECCD9AD.TMP' is not a
valid Win32 resource file
There are a number of projects in my solution and the project for which I get this error changes randomly.
I have to compile and interrupt several times before I am able to complete the compilation. When I interrupt the build process I get the following error:
Microsoft Visual Studio Debugging Monitor (MSVSMON.EXE) failed to
start. If this problem persists, please repair your Visual Studio
installation via 'Add or Remove Programs' in Control Panel.
--------------------------- OK
--------------------------- 4
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(316,9):
error MSB4018: The "Csc" task failed unexpectedly.
4>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(316,9):
error MSB4018: System.InvalidOperationException: No process is associated with this object.
4>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319 Microsoft.CSharp.targets(316,9):
error MSB4018: at System.Diagnostics.Process.EnsureState(State state)
4>C:\WINDOWS\Microsoft.NET\Framework\v4.0.303\Microsoft.CSharp.targets(316,9):
error MSB4018: at System.Diagnostics.Process.get_HasExited()
4>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(316,9):
error MSB4018: at Microsoft.Build.Utilities.ToolTask.TerminateToolProcess(Process proc, Boolean isBeingCancelled)
4>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(316,9):
error MSB4018: at
Microsoft.Build.Utilities.ToolTask.HandleToolNotifications(Process
proc)
4>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(316,9):
error MSB4018: at
Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool,
String responseFileCommands, String commandLineCommands)
4>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(316,9):
error MSB4018: at Microsoft.Build.Utilities.ToolTask.Execute()
4>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(316,9):
error MSB4018: at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
4>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(316,9):
error MSB4018: at
Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
I am getting the same error with other versions of visual studio. So it looks like an issue with csc.exe.
I have tried all the fixes that I could find on google, including re-installation, repair and uninstallation of .net frameworkds, visual studio. The only option that is left with me is to format my computer and build my dev environment from scratch.
Any help in resolving this will would be greatly appreciated.