Do .NET AppDomains only isolate .NET assemblies; that is, do C-style DLLs always get shared across AppDomains?
I have a C# framework that uses Nuget package HDF.PInvoke to create a simpler API for reading/writing .h5 files. Under the hood, that HDF.PInvoke wrapper calls into C-style HDF5.DLL. All framework interaction with HDF.PInvoke is done in one class in its own
assembly, HDFWrapper. HDFWrapper is loaded in a separate AppDomain and AppDomain.CurrentDomain.GetAssemblies()
verifies that HDFWrapper is not loaded into the primary AppDomain.
However, an app built on this framework that has its own direct dependencies on a different version of HDF5.dll crashes when it tries to access that DLL. Suspecting version conflict, I temporarily replaced the framework's copy of HDF5.dll with the one needed by the app and voila the app works (but the framework's use of HDF.PInvoke breaks).
The framework loads its copy of HDF5.dll before the app does. Unfortunately, I can't tell what the visibility of that module is from the list returned by ProcessModuleCollection processModuleCollection = Process.GetCurrentProcess().Modules;
since
it doesn't indicate anything about AppDomains. And C-style DLLs aren't included in the list returned by Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
For performance reasons, I can't move HDFWrapper into its own process.