Open baruchiro opened 5 years ago
It is more complicated from that.
About the Assembly.Load("netstandard")
and .NET Framework
, if I try to load it, it is not found. But if I don't load it, I get many exceptions about he is missing.
Meanwhile, I added this assembly file to my repository and I reference his location.
About the Assembly.Load("netstandard") and .NET Framework, if I try to load it, it is not found. But if I don't load it, I get many exceptions about he is missing.
@baruchiro I was able to load netstandard
assembly from .NET Framework when I specified its full name:
Assembly assembly = Assembly.Load("netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51");
With @JosefPihrt‘s reply, I think we can close the issue, can’t we? /close
Version Used: Nuget
Microsoft.CSharp Version=4.5.0
What are we trying to do?
My company has a very large base code, and one of the libraries compiles lots of C# code at runtime. We are trying to support .NET Core, and for this purpose, we are currently assembling the libraries to netstandard2.0, and the executable is coming out to certain customers in the .NET Framework and to other customers in the .NET Core.
We don't understand what is the right way to load the correct Assemblies according to TargetFramework:
For .NET Framework:
But if we call this library from a
.NET Core
dll, we must add more assemblies likes these, to compile the same code:But then, this code doesn't support
.NET Framework
anymore, because in.NET Framework
, there is one assembly for all references, and thenetstandard
orSystem.Runtime
are not exists.So, we search for a common way to load assemblies for both
.NET Core
and.NET Framework
.From this Wiki page, we tried to use
AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES")
, but again, for.NET Core
it return a list of requierded dll's, but for.NET Framework
it returnnull
.There is a common way to accomplish that, or we should load the assemblies by checking the
Assembly.GetEntryAssembly().ImageRuntimeVersion
?