You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently there's no way to unload unmanaged dynamic libraries while using P/Invoke.
Sometimes we need to hot-upgrade without restarting host process, absolutely that we can use LoadLibrary/FreeLibrary to achieve that but it's really inconvenient, and also we cannot invoke methods in dll directly by calling their method names/ordinals.
So I think it is necessary to provide a mechanism for unloading/reloading dlls while using P/Invoke.
The text was updated successfully, but these errors were encountered:
hez2010
changed the title
Feature Request: A mechanism for unloading and reloading unmanaged libraries using P/Invoke
Feature Request: A mechanism for unloading and reloading unmanaged libraries while using P/Invoke
Apr 22, 2019
This isn't something we are likely to change via the DllImport approach. There are several reasons, but mostly it will lead to invalid P/Invoke stubs that could result in unsafe execution if the associated native library is unloaded.
absolutely that we can use LoadLibrary/FreeLibrary to achieve that but it's really inconvenient, and also we cannot invoke methods in dll directly by calling their method names/ordinals.
Agreed. The proposed C# function pointer feature along with the NativeLibrary should make much
of this less onerous.
I guess this is one more dynamic approach how to proceed. But would it be possible to introduce some additional function call to release loaded library, which was used with [DllImport] attribute.
Then [DllImport] can be used as such, without need to coding everything dynamically via NativeLibrary.
Btw, one approach is to create customized [DllImport], which would in a turn use NativeLibrary, and provide function for release loaded dll. (Reinvent the wheel)
ghost
locked as resolved and limited conversation to collaborators
Dec 13, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Currently there's no way to unload unmanaged dynamic libraries while using P/Invoke.
Sometimes we need to hot-upgrade without restarting host process, absolutely that we can use LoadLibrary/FreeLibrary to achieve that but it's really inconvenient, and also we cannot invoke methods in dll directly by calling their method names/ordinals.
So I think it is necessary to provide a mechanism for unloading/reloading dlls while using P/Invoke.
The text was updated successfully, but these errors were encountered: