Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to dynamically load dotnet assemblies at runtime.

Let's say I have netcore 3.1 console app:

  • Can I load .net standard assemblies? If yes what specific version I can load?
  • Can I load classic .net assemblies, like .net framework 4.8? If yes can I also load older versions?

What about reverse situation, when I have dotnet framework 4.8 console app:

  • Can I load .net standard assemblies?
  • Can I load older classic .net, like assemblies,.net framework 4.6?
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
174 views
Welcome To Ask or Share your Answers For Others

1 Answer

.NET Standard is an interface - a versioned list of APIs that you can call.

.Net standard can be referenced by both .NET framework and .NET core.

What does this mean?

You should use .Net standard for class libraries.

.NET framework and .NET core those two target a platform. .Net framework only works on Windows while .Net core works on all three(Windows/Linux/MacOS) operating systems. These should not reference one another.

This is why .Net standard exists.

So to quickly answer your questions.

  • Can I load .net standard assemblies? If yes what specific version I can load? Yes, you should use .Net standard
  • Can I load classic .net assemblies, like .net framework 4.8? If yes can I also load older versions? You probably can, for sure you should not

What about reverse situation, when I have dotnet framework 4.8 console app:

This is for .NET Standard. Taken from Microsoft Docs.

The documentation is very clear on what you need to pay attention to. The text below is similar to the one in the screenshot. I added here to be more readable.

The following table lists the minimum platform versions that support each .NET Standard version. That means that later versions of a listed platform also support the corresponding .NET Standard version. For example, .NET Core 2.2 supports .NET Standard 2.0 and earlier.

Guide

In addition to this ->https://docs.microsoft.com/en-us/dotnet/standard/net-standard#net-implementation-support

enter image description here

In order to avoid targeting errors and transitive dependencies errors or at least keep them to a minimum. Change your package management to PackageReference when using .NET standard.

<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

The link below provides the full info and also some troubleshooting tips for such errors.

Source: https://www.hanselman.com/blog/ReferencingNETStandardAssembliesFromBothNETCoreAndNETFramework.aspx


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...