[Mono-devel-list] [patch]Patch DllNotFoundException triggered for missing unmanaged libraries

Denis Gervalle dgl at softec.st
Wed Jun 2 04:50:00 EDT 2004


Here is an updated patch against Beta2 to introduce a better error
reporting when loading unmanaged libraries. It needs MONO_DEBUG to be
define.

Hope we will get checked-in this time or at least receive some comments
on why we are not.

For those who have missed the full story, here is a summuary:
We have written this patch (and enhance it latter) after seaching hard
in the dark why a dynamic library next to our mono assembly is
presumably not found (DllNotFoundException) by mono.
The attached patch (based on the beta release) modify the triggered
exception when MONO_DEBUG is defined to provide a larger error message
corresponding to the joined error message of all tries done using
g_module_open(). Here is a sample:

Unhandled Exception: System.DllNotFoundException: Trying libsample.so:
libsample.so: cannot open shared object file: No such file or directory
==> Trying ./libsample.so: ./libsample.so: cannot open shared object
file: No such file or directory ==> Trying sample.so:
libdependancy.so.0: cannot open shared object file: No such file or
directory

This patch also provide a detailled error report of missing entry points
in unmanaged library using the same technique.
This patch takes care of mint issues and mono pinvoke-wrapper issues.
For the latter, each exception messages are allocated permanently on the
heap since the exception is triggered by the wrapper code for each call
to a function from the missing library (and not during the loading
phase). This is why MONO_DEBUG is required to activate the code, since
it could leak memory if a lot of missing library are tried.


Denis Gervalle
SOFTEC sa
http://www.softec.st




More information about the Mono-devel-list mailing list