You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
System.Runtime.Loader not copied to output directoryΒ #22732
I'm using 2.0.0-preview1-25305-02 and I have an issue with mixed netstandard and net462 projects in the same solution. Not sure if I'm doing something wrong or if there's something else.
I have a net462 app that loads another net462 dll containing some Unity hosting code. That in turn loads some other dlls, some of which are netstandard2.
On app startup I'm getting:
---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I had thought this was part of netstandard, but either way I've added it as a NuGet package dependency to the Unity project (seeing as that's the one that does dynamic loading), but for some reason it's not ending up in either the Unity project bin folder or the exe one. Do you know why this dll is not being deployed to the bin folder?
If I drop in a dll from C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime.loader\4.3.0\lib\netstandard1.5 then I get:
Resolving FIS.Risk.Core.Logging.NullLogger,(none) (mapped from FIS.Risk.Core.Logging.ILogging, (none))
---> System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
If I drop in from C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime.loader\4.0.0\lib\netstandard1.5 then I get:
Resolving FIS.Risk.Core.Logging.NullLogger,(none) (mapped from FIS.Risk.Core.Logging.ILogging, (none))
---> System.TypeLoadException: Could not load type 'System.Runtime.Loader.AssemblyLoadContext' from assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
hey @bencyoung , have you tried this again with netcoreapp/netstandard 2.0? I ask because we added some tooling fixes that would add a reference to a compatibility package that will make referencing net461 dependencies work, so I wonder of that fixes your problem. Let me know if you still see the issue.
A problem occurred when trying to run the application.: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral,...'
at FIS.Risk.Core.Hosting.ComponentRunner.RunnerState..ctor(IReadOnlyList`1 args, IComponent component, Action hostingStop, Action hostingRestart, TimeSpan joinWait)
at FIS.Risk.Core.Hosting.ComponentRunner.RunAsConsole(IReadOnlyList`1 args)
Having the exact same issue, something is definitely wrong here. Side by side .netcore 2/4.7.1/.NET Standard 2 and System.Runtime.Loader is never copied. Blows up standard dependency injection code using AssemblyLoadContext
Reacted by James J, Mansour Ghaoui, Pablo Castilla, Adam Driscoll, Fitzchak Yitzchaki, Per Samuelsson, Mike van Oorschot, Michael Yu, Radenko Zec, Yusuke Ito and 5 more
I am facing the same issue with .Net framework 4.6.1 with some reference to .Net Standard 2.0 libraries.
Please share workaround or resolution to this.
@nikunjratanpara When using the full framework, I went back to the traditional 'Assembly.Load' methods. Very unfortunate, but not way around this as we speak.
I'm having the same issue as @phatcher with .Net 4.6.1 as the target while running unit tests. Is it not possible to use a .Net Standard 2.0 library in a .Net Framework project? That would seem to negate the entire purpose of having .Net Standard at all.
System.Runtime.Loader is not supported on desktop: full stop. You cannot use it there, we have no implementation of this API on .NETFramework. It's current failure mode (FileNotFoundException) is by design, we can talk about changing that (eg: PlatformSupportedException) but I suspect that's not really going to help enable whatever that's attempting to use this API.
If the ask is to support this API on desktop folks should start describing the scenarios they want to work and folks like @jeffschwMSFT and @jkotas can have a look provide a recommendation.
What I'm asking for is the ability to use a .Net Standard library built with .Net Core in a .Net 4.6 Framework project. When I run unit tests in Azure with this scenario the tests crash.
@jons-aura can you open a new issue describing that? It sounds different than what this issue is tracking (System.Runtime.Loader, specifically). I suspect you are hitting a case of missing the support libraries from your .NET Framework 4.6.1 project, but it'd be best to open a new issue that describes the issue and along with a repro if you can. Important things to note are the projects involved, their target frameworks, how they reference each other, and whether they are using nuget-packages.config vs nuget-packagereference. Tag me @ericstj on the new issue and I'll have a look. Thanks!
@ericstj My problem I think is that netframework/netcore binaries are getting mixed up during the compilation phase on Azure DevOps causing the "Could not load error..." since it's only supported on netcore
All of my projects are using packagereference and the source nuget packages are targeting both netstandard and netframework and I have the settings as below
I've also checked and the vstest.console is only picking up net472 test assemblies though the test adapter path is as per @jons-aura case to "D:\a\1\s"
It's difficult getting to a simple repo as it's a 60 project solution that's failing, whereas the 85 project solution with the library code compiles and tests correctly on DevOps; which is why I think it's some form of errant reference but I've been through the project files a number of times trying to find it.
It is not clear here what (if anything) should be fixed in the runtime repo as most people hitting this problem are usually due to a misconfiguration on their project causing .NET Core libraries to end up on their .NET Framework applications. For this reason I'll go ahead and close this issue for now but feel free to reopen if you think otherwise.
Activity
bencyoung commentedon Jul 12, 2017
The Fusion log looks like
jnm2 commentedon Jul 12, 2017
I'm interested, running into a similar issue with NUnit.Xamarin too on monoandroid71.
bencyoung commentedon Jul 12, 2017
If I drop in a dll from C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime.loader\4.3.0\lib\netstandard1.5 then I get:
Resolving FIS.Risk.Core.Logging.NullLogger,(none) (mapped from FIS.Risk.Core.Logging.ILogging, (none))
---> System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
bencyoung commentedon Jul 12, 2017
If I drop in from C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime.loader\4.0.0\lib\netstandard1.5 then I get:
Resolving FIS.Risk.Core.Logging.NullLogger,(none) (mapped from FIS.Risk.Core.Logging.ILogging, (none))
---> System.TypeLoadException: Could not load type 'System.Runtime.Loader.AssemblyLoadContext' from assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
joperezr commentedon Sep 25, 2017
hey @bencyoung , have you tried this again with netcoreapp/netstandard 2.0? I ask because we added some tooling fixes that would add a reference to a compatibility package that will make referencing net461 dependencies work, so I wonder of that fixes your problem. Let me know if you still see the issue.
bencyoung commentedon Sep 26, 2017
I'm still getting the issue unfortunately.
bencyoung commentedon Sep 26, 2017
The version of System.Runtime.Loader that's ending up in the bin folder is:
bencyoung commentedon Sep 26, 2017
Here's a minimal reproduction
BugDemo.zip
DVoavi-Arison commentedon Oct 2, 2017
Running into the same issue with loader 4.3.0 even if I do copy the dll itself to the output folder before running.
aienabled commentedon Oct 25, 2017
Same issue with System.Runtime.Loader 4.3.0 and net471.
UPD. Found this https://github.com/dotnet/cli/issues/6019
sereeth commentedon Dec 20, 2017
Having the exact same issue, something is definitely wrong here. Side by side .netcore 2/4.7.1/.NET Standard 2 and System.Runtime.Loader is never copied. Blows up standard dependency injection code using AssemblyLoadContext
jugg1es commentedon Feb 12, 2018
any resolution to this?
bobuva commentedon Jul 20, 2018
Asking if there's any resolution to this.
nikunjratanpara commentedon Jul 29, 2018
I am facing the same issue with .Net framework 4.6.1 with some reference to .Net Standard 2.0 libraries.
Please share workaround or resolution to this.
alexdegroot commentedon Jul 29, 2018
@nikunjratanpara When using the full framework, I went back to the traditional 'Assembly.Load' methods. Very unfortunate, but not way around this as we speak.
12 remaining items
jons-aura commentedon Feb 15, 2019
I'm having the same issue as @phatcher with .Net 4.6.1 as the target while running unit tests. Is it not possible to use a .Net Standard 2.0 library in a .Net Framework project? That would seem to negate the entire purpose of having .Net Standard at all.
watsonsong commentedon Mar 15, 2019
I met the same problem when I use .netcore 3.0 preview, is there any one met the same problem?
ericstj commentedon Mar 15, 2019
@phatcher / @jons-aura / @watsonsong can you all clarify what it is you're asking?
System.Runtime.Loader is not supported on desktop: full stop. You cannot use it there, we have no implementation of this API on .NETFramework. It's current failure mode (FileNotFoundException) is by design, we can talk about changing that (eg: PlatformSupportedException) but I suspect that's not really going to help enable whatever that's attempting to use this API.
If the ask is to support this API on desktop folks should start describing the scenarios they want to work and folks like @jeffschwMSFT and @jkotas can have a look provide a recommendation.
jons-aura commentedon Mar 15, 2019
What I'm asking for is the ability to use a .Net Standard library built with .Net Core in a .Net 4.6 Framework project. When I run unit tests in Azure with this scenario the tests crash.
ericstj commentedon Mar 15, 2019
@jons-aura can you open a new issue describing that? It sounds different than what this issue is tracking (System.Runtime.Loader, specifically). I suspect you are hitting a case of missing the support libraries from your .NET Framework 4.6.1 project, but it'd be best to open a new issue that describes the issue and along with a repro if you can. Important things to note are the projects involved, their target frameworks, how they reference each other, and whether they are using nuget-packages.config vs nuget-packagereference. Tag me @ericstj on the new issue and I'll have a look. Thanks!
phatcher commentedon Apr 13, 2019
@ericstj My problem I think is that netframework/netcore binaries are getting mixed up during the compilation phase on Azure DevOps causing the "Could not load error..." since it's only supported on netcore
All of my projects are using packagereference and the source nuget packages are targeting both netstandard and netframework and I have the settings as below
I've also checked and the vstest.console is only picking up net472 test assemblies though the test adapter path is as per @jons-aura case to "D:\a\1\s"
It's difficult getting to a simple repo as it's a 60 project solution that's failing, whereas the 85 project solution with the library code compiles and tests correctly on DevOps; which is why I think it's some form of errant reference but I've been through the project files a number of times trying to find it.
apobekiaris commentedon Aug 27, 2019
worked for me after upgrading to 4.8
CleverAtBen commentedon Nov 5, 2019
@phatcher Did you solve your problem?? I am experiencing exactly the same experience on Azure DevOps
joperezr commentedon Jul 1, 2020
It is not clear here what (if anything) should be fixed in the runtime repo as most people hitting this problem are usually due to a misconfiguration on their project causing .NET Core libraries to end up on their .NET Framework applications. For this reason I'll go ahead and close this issue for now but feel free to reopen if you think otherwise.