natemcmaster/DotNetCorePlugins

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

Mansterteddy opened this issue · 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?

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.

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