[Mono-list] Question about the lifetime of libraries loaded by a p/invoke

Robert Jordan robertj at gmx.net
Mon Jul 21 18:56:58 EDT 2008


Maser, Dan wrote:
>   The simple question is this:  When a .dll or .so is loaded by the
> framework as the result of a p/invoke is that library guarenteed to stay
> loaded for the duration of the hosting process?  Or can the framework
> unload the dll if it wants to?  Is there anything in a spec that
> indicates a standard behavior?  I've been trying to get this from the
> microsoft documentation but I can't seem to find anything.

On MS.NET and Mono, P/Invoke libraries are treated like a compile
time assembly reference and are never unloaded.

If you want to unload native libraries you have to handle them
with the machinery provided by the OS (dlopen, dlclose, LoadLibrary,
etc.).

Robert



More information about the Mono-list mailing list