Good day. There is a C # application in which managed and unmanaged dll files are loaded during work. It is necessary to implement a dynamic reload of these dll'ok. C managed dll problems do not arise - I create an additional domain and load them into it, and then unload the entire domain. Unmanaged dll'ki, as I understand it, do not interact with the domain and need a different mechanism. I tried to free them and load again with:
[DllImport("kernel32.dll", CharSet = CharSet.Auto)] static extern bool FreeLibrary(IntPtr hModule); [DllImport("kernel32.dll")] static extern IntPtr LoadLibrary(string dllToLoad); But when trying to reuse classes from these libraries, an Access Violation exception is thrown. I suspect that when using FreeLibrary, the libraries are unloaded, but there are pointers to them in clr and an exception is thrown when trying to use it.
The question is: is there any way to unload and reload the unmanaged dll and then use them.
FreeLibrary? Can leave dll in memory? - nick_n_a