Running tasks compiled for netcore throws ReflectionTypeLoadException
See original GitHub issueWhen I simply run my task as part of MSBuild, it works as expected. AFAIR, I was able to run/debug it specifically StructuredLogViewer, but yesterday it failed on me.
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at TaskRunner.Executor.Execute(Task task) in C:\MSBuildStructuredLog\src\TaskRunner\Executor.cs:line 32
at TaskRunner.Program.Run(String binlog, Int32 index, String taskName) in C:\MSBuildStructuredLog\src\TaskRunner\Program.cs:line 114
at TaskRunner.Program.Main(String[] args) in C:\MSBuildStructuredLog\src\TaskRunner\Program.cs:line 61
One of the assemblies is System.Runtime
:
=== Pre-bind state information ===
LOG: DisplayName = System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Users/matthias.koch/AppData/Local/MSBuildStructuredLogViewer/app-2.1.208/
LOG: Initial PrivatePath = NULL
Calling assembly : CustomTasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Users\matthias.koch\AppData\Local\MSBuildStructuredLogViewer\app-2.1.208\TaskRunner.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///C:/Users/matthias.koch/AppData/Local/MSBuildStructuredLogViewer/app-2.1.208/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Users/matthias.koch/AppData/Local/MSBuildStructuredLogViewer/app-2.1.208/System.Runtime/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Users/matthias.koch/AppData/Local/MSBuildStructuredLogViewer/app-2.1.208/System.Runtime.EXE.
LOG: Attempting download of new URL file:///C:/Users/matthias.koch/AppData/Local/MSBuildStructuredLogViewer/app-2.1.208/System.Runtime/System.Runtime.EXE.
LOG: Attempting download of new URL file:///C:/code/custom-msbuild-task/src/CustomTasks/bin/Debug/netcoreapp2.1/publish/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/code/custom-msbuild-task/src/CustomTasks/bin/Debug/netcoreapp2.1/publish/System.Runtime/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/code/custom-msbuild-task/src/CustomTasks/bin/Debug/netcoreapp2.1/publish/System.Runtime.EXE.
LOG: Attempting download of new URL file:///C:/code/custom-msbuild-task/src/CustomTasks/bin/Debug/netcoreapp2.1/publish/System.Runtime/System.Runtime.EXE.
Anything else I can provide to give more insight?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
ReflectionTypeLoadException in ASP.NET Core MVC ...
An unhandled exception has occurred: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more ...
Read more >System.Reflection.ReflectionTypeLoadException when ...
According to the exception in your logs, the analyzer your project is trying to load is relying on some type that is unavailable....
Read more >ReflectionTypeLoadException when running dnx (aspnet5)
Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property at System.
Read more >What is System.Private.CoreLib.dll and why is it giving me ...
When I run the build from visual studio I get an error message in the Development Console saying: Error could not find assembly...
Read more >How to resolve “Could not load file or assembly … or one of its ...
Cached Assembly: Check the same assembly bound before then use it, if it failed then current request is failed immediately without any further...
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
@KirillOsenkov arg! I actually thought about this but must have forgotten to update one of the references. Can confirm that it’s working with
net472
just fine. Thanks for your quick response! ❤️Quick repro steps to get the binlog:
C:/Program Files/dotnet/sdk/3.1.401/MSBuild.dll
and change to whatever you have installed$task CustomTask
, right-click and Run or DebugExpected: should work
Actual: ReflectionTypeLoadException because trying to load a task assembly targeting .NET Core on a .NET Framework process.