Home > Back-end >  Running library for framework 4.8 for a .NET 6 API
Running library for framework 4.8 for a .NET 6 API

Time:01-28

I've seen a few conflicting answers about this topic so I'm hoping someone can lead to the right one. I'm building an API that uses devdept Eyeshot library. This library requires .net framework 4.8. I would like to use .NET 6 for my API because from what i can tell, Framework does not have great tools when it come to web development.

I've tried two different set-up's for my solution:

.NET 6 API with a .NET 6 class library where i tried to reference the relevant framework library.

.NET 6 API with framework 4.8 class library.

When I call the class i get the error -"Could not load type 'System.Runtime.Remoting.RemotingServices' from assembly 'mscorlib, Version=4.0.0.0'". But when i run it from a framework 4.8 API it works.

So is there and why at all to get this working with a .NET 6 API, no matter how complicated or does the API have to target the same framework?

CodePudding user response:

You are out of luck unless there is an updated version. The remoting services it depend upon has been removed in the .Net core & .Net 5 . So the library will fail to load, at least if the jitter ever reaches any method that uses one of the removed APIs.

If this is a first party or open source library you might consider updating to .Net 5 , and replace the remoting service with some newer IPC technology. If it is third party commercial library you might politely ask them to update their library, it should be in their own interest since most libraries already have transitioned to .net 5 .

If that is not an option, a possible workaround is to run the library in a separate process, and use your favorite IPC/RPC method to communicate with this processes.

CodePudding user response:

In addition to the other answer (I was just going to post something similar), do note that when you reference a .NET Framework library from a .NET 6.0 app, the entire code will run in the .NET 6.0 runtime. There's no second execution environment created, therefore the .NET Framework library actually executes against the .NET 6.0 runtime library and fails if it requires features that no longer exists there. Many older libraries work fine that way, since the runtime is mostly backwards compatible, with some notable exceptions. 'System.Runtime.Remoting.RemotingServices is one of them.

  • Related