load/unload C dll with C# problems
- by Goran
I'm having problems with external native DLL.
I'm working on ASP.NET 1.1 web application and have this DLL which I load through DLLImport directives.
This is how I map DLL functions:
[DllImport("somedllname", CallingConvention=CallingConvention.StdCall)]
public static extern int function1(string lpFileName,string lpOwnerPw,string lpUserPw);
[DllImport("somedllname", CallingConvention=CallingConvention.StdCall)]
public static extern int function2(int nHandle);
I call the dll methods and all works great, but I have problems with this DLL crashing my web site on some cases, so I would like an option to unload the dll after I use it.
I found a solution at this link, but I don't have 'UnmanagedFunctionPointer' attribute in .NET 1.1 available.
http://blogs.msdn.com/jonathanswift/archive/2006/10/03/Dynamically-calling-an-unmanaged-dll-from-.NET-_2800_C_23002900_.aspx
Is there a way I can achieve what this guy did with his example?