简体   繁体   中英

.NET 5 Project not really working with old 3rd Party .NET Framework 2.x/4.x assemblies

I am currently working with a new C# .NET 5 Blazor Project. As we "upgraded" our Application from an .NET 4 Framework (new project using old code) I am currently running into one issue i am not able find any solution.

The issue: I wrote code using a 3rd party assembly. This 3rd Party assembly with the latest version to get is targeting .NET 4.8. Now this 3rd Party assembly is throwing exceptions due to accessing parts of the AppDomain which are not present anymore in the .NET 5 Framework (AppDomain.CurrentDomain.SetupInformation.ConfigurationFile). As microsoft removed or changed the way of how AppDomains are used now in .NET 5.

Now my question is. Is there any way to get the 3rd party assembly still loaded that it targets and uses the .NET Framework 4.8 instead of the main projects .NET 5 Framework? Tho that I am still able to use it (no exception should be thrown as the AppDomain code is present in the .NET 4.x), without having to wait for the company to adapt the assembly to support .NET 5?

I tried using the "AssemblyLoadContext" but had no success till now.

Thank You for any Information or Help! Stay Safe!

Unless otherwise specified, new major versions of.Net should be presumed to be incompatible with older versions. However, there seem to be quite a few exceptions to this rule.

  • .Net 4 could usually load.Net 3.x assemblies just fine
  • .Net 5 is as far as I can tell mostly backward compatible with.Net core 3

The change from.Net framework 4.8 to.Net core and.Net 5 have been quite significant. While there have been quite a bit of work to make the transition smoothly, there are some features that have simply been removed from.Net 5:

There are some technologies that will remain .NET Framework specific, such as AppDomains, Remoting, etc, WCF Server and WWF.

Source: .net 5 backward compatiblity with .net framework?

The solution should be to Update any third party libraries to versions targeting .net standard, .net core or.Net 5. Most of the popular libraries seem to have been updated already.

If this is not possible you might want to consider to politely request libraries to be updated by the author, or update the libraries yourself in case they are open source.

As last resort you might want to replace the libraries with something else that do support the newest.Net versions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM