ThrowExceptionForHR from an SDK task fails due to missing resource
See original GitHub issueAn MSBuild task in this repo that calls Marshal.ThrowExceptionForHR fails due to a missing resource assembly:
d:\sdk\artifacts\Debug\bin\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(308,5): error MSB4018: System.IO.FileNotFoundException: Could not load the specified file. [d:\sdk\artifacts\Debug\tmp\It_contains_r---AB2009D8\ResourceTest\ResourceTest.csproj]
d:\sdk\artifacts\Debug\bin\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(308,5): error MSB4018: File name: 'Microsoft.Build.Tasks.CodeAnalysis.resources' [d:\sdk\artifacts\Debug\tmp\It_contains_r---AB2009D8\ResourceTest\ResourceTest.csproj]
d:\sdk\artifacts\Debug\bin\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(308,5): error MSB4018: at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName) [d:\sdk\artifacts\Debug\tmp\It_contains_r---AB2009D8\ResourceTest\ResourceTest.csproj]
d:\sdk\artifacts\Debug\bin\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(308,5): error MSB4018: at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName) [d:\sdk\artifacts\Debug\tmp\It_contains_r---AB2009D8\ResourceTest\ResourceTest.csproj]
d:\sdk\artifacts\Debug\bin\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(308,5): error MSB4018: at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) [d:\sdk\artifacts\Debug\tmp\It_contains_r---AB2009D8\ResourceTest\ResourceTest.csproj]
I’m not sure why this specific resource is needed by ThrowExceptionForHR. It looks like it may be caused by https://github.com/dotnet/roslyn/issues/26777.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
missing resource exception - java
MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key Content Management Exception.
Read more >IDisposable: What Your Mother Never Told You About ...
One difficulty of the IDisposable interface overcome with the Disposable Design Principle.
Read more >MSBuild Error - SDKs missing
Hi, I'm setting up Bamboo for a .NET application. When I tried to perform MSBuild or Nuget restore task thru script, I get...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is fixed.
After merging master and accounting for test rename in command shown below, the appropriate exception is raised:
That stack trace is very odd.
It is possible that latest Roslyn will fix this as the build task no longer does assembly resolve shenanigans. It might also change the symptom to something more decipherable. I will focus on that and then look at this.