I am doing a P/Invoke, and I am using the following method
[DllImport("Authz.dll", SetLastError = true)]
public static extern BOOL AuthzFreeContext(
IntPtr phAuthzResourceManager);
even though its working, how is it guaranteed that Authz.dll
is always loaded into my code. Suppose my dll
is some XXX.dll
how should I check in general if that dll is loaded or not before using that, so that I don't get a method not found exception.
Marshal.PrelinkAll(Type)
or
Marshal.Prelink(MethodInfo)
Sadly, the documentation fails to mention any exceptions being thrown if the DLL is not found. I have just verified via a simple app that it is indeed a DllNotFoundException
being thrown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With