Multiple applications calling the same unmanaged dll

A .NET 3.5 C # application creates several application domains. Each appdomain loads the same unmanaged third-party dll. This DLL reads the configuration file during initialization. If the configuration changes at runtime, the dll needs to be unloaded and loaded again. This dll is not in our area to rewrite correctly.

Does each appdomain support a separate copy of this unmanaged dll, or does Windows store one copy of the dll and support usage counting? If the latter is the case, how do we get each instance of an unmanaged dll to reflect its unique configuration?

+4
source share
2 answers

Takea take a look at this blog post

Explanation of processes and AppDomains

+2
source

I think that unmanaged DLLs are loaded only once for each OS process, so each application domain will have the same loaded instance. To offload the dll, use the FreeLibrary function. However, since several application domains probably loaded the dll, there is no guarantee that FreeLibrary will actually free / unload the dll from the same application domain.

As BillW says, this also sounds like a design nightmare!

0
source

Source: https://habr.com/ru/post/1305075/


All Articles