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

Denis Gervalle dgl at softec.st
Wed Jun 2 13:04:23 EDT 2004

Peter Dennis Bartok wrote:

 >I was under the impression that we already print the detailed error why a
 >module could not be loaded if MONO_DEBUG is set. Gonzalo put that in 
for me
 >quite a while ago. Did I miss something?

Yes, Gonzalo has made one correction, but this one only partially report 
the problem. In fact, to keep a good compatibility between Windows and 
Linux, mono try to load up to 6 variations on the library name. Gonzalo 
current correction only report the error provided by the latest tried 
name. But, if a previous name succeed but failed on a library 
dependancy, this is not shown, so it currently report 
DllNotFoundException: sample.so, but a libsample.so may have been found 
and failed on its dependencies.

Using name variations may also create a confusion, since for example, 
./libsample.so is tried before sample.so, if both are available 
(probably a poor name have been choosen), and  both provide different 
symbols as entry points,  you may get a EntryPointNotFoundException 
because the library loaded is not the one you expect. Moreover, 
entrypoint symbol also use variations for Unicode/Ansi function, and 
this may cause even more confusion. The patch provided address these 
issues by providing a full report of all tried libraries, and also tried 
symbols so you can quickly understand what is going on.

Taking my last example, using

extern mysymbol()

and a call to that function as the first function of that library

Under linux, with two library ./libsample.so not containing mysymbol and 
/usr/lib/sample.so containing mysymbol (I admit, a really weird 
situation), you will get an EntryPointNotFoundException and the 
following message (if MONO_DEBUG is set):

Trying 'libsample.so': libsample.so: cannot open shared object file: No 
such file or directory ==> Trying ./libsample.so: Found ==> Searching 
function 'mysymbolA': 'mysymbolA': mono: undefined symbol: mysymbolA ==> 
Searching function 'mysymbol': 'mysymbol': mono: undefined symbol: mysymbol

Hopes that this helps clarify all purposes of the patch.

Denis Gervalle

More information about the Mono-devel-list mailing list