DotNetCorePlugins icon indicating copy to clipboard operation
DotNetCorePlugins copied to clipboard

[Question] How to load multi versions of dependencies of native libraries?

Open Mansterteddy opened this issue 4 years ago • 2 comments

Thanks for building this great library!

I have a question for loading dependencies of native libraries: I want to load two native libraries, let’s call them A.dll and B.dll each of which lives in its own directory and carries additional native dependencies. Some of these dependencies are the same name, but different versions. So for example A depends on Utils.dll V1 and B depends on Utils.dll V2.

I want to use the A and B libraries via DllImport in different plugins, and let each A and B load their own copy of Utils,dll.

Can DotNetCorePlugins support such cases?

Mansterteddy avatar Dec 17 '21 04:12 Mansterteddy

It should work to the extent that .NET allows multiple native libraries of different versions. This plugin library relies on the AssemblyLoadContext API in .NET. I haven't seen experimented much with native libraries myself so can't say what issues you might hit. See https://docs.microsoft.com/en-us/dotnet/core/dependency-loading/understanding-assemblyloadcontext for more details about what AssemblyLoadContext does.

natemcmaster avatar Dec 20 '21 00:12 natemcmaster

Thanks for your answer, Nate! I will take a look.

Mansterteddy avatar Dec 20 '21 02:12 Mansterteddy