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

Paolo Molaro lupus at ximian.com
Tue Jul 22 09:45:44 EDT 2008


On 07/21/08 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.

I don't think this is documented anywhere for the MS runtime,
if anyone has a definitive answer for that let me know.

For mono consider the following to be the documentation:
1) we currently don't unload the shared libraries once opened
2) this behaviour is not guaranteed and it could change in the future
3) if the library will get unloaded, that will happen at application
domain unload time (assuming it's not used in other appdomains).
4) it is guaranteed that invoking a non-existent method in an
existing shared library will cause the library to be kept open
(this is required to be able to work around the many cases where shared
libraries are not linked correctly with their dependencies)

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better


More information about the Mono-list mailing list