load/unload C dll with C# problems

Posted by Goran on Stack Overflow See other posts from Stack Overflow or by Goran
Published on 2010-04-12T18:36:39Z Indexed on 2010/04/12 18:43 UTC
Read the original article Hit count: 393

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about c

    Related posts about dll