Releasing a native DLL

  • Thread starter Thread starter Mike King
  • Start date Start date
M

Mike King

How can we get ASP.NET/CLR to release a native DLL when using P/Invoke. We
are building a web application that uses a native DLL heavily. It's
unlikely that we will ever have a Managed DLL because of the 3rd party
static library (.LIB) file that we're using. The problem is that when one
of the pages that uses the native DLL is requested, the native DLL becomes
locked. We need the CLR to release the native DLL because when we go live,
we won't have control of the Web Server so we can't run "iisreset." I'm
guessing P/Invoke builds a proxy between the Managed DLL and the native DLL
an the proxy locks the DLL until it's garbage collected. Since the GC is
non-deterministic it's difficult to know when the native DLL will be
released. Does anyone know of a solution to this problem?
 
..net has no support for unloading a dll, only an AppDomain.

if you need the ability to unload a dll, you need to load it in its own
appdomain which you can unload at will. you will need to use a remoteing
proxy that calls the P/Invoke to talk across domains, so watch perfomance.
see "Programing with Application Domains".


-- bruce (sqlwork.com)
 
Back
Top