[Mono-list] Some questions about shared assemlies, strong names...

Fergus Henderson fjh@cs.mu.OZ.AU
Mon, 5 May 2003 23:25:39 +1000


On 05-May-2003, Paolo Molaro <lupus@ximian.com> wrote:
> On 05/04/03 Fergus Henderson wrote:
> > Having hit a name clash already (for "gc.dll") when trying to port
> > Mercury to run on Mono, I am probably more sensitive to this issue
> > than most ;-).  I still haven't solved that, BTW.
> 
> If I remember correctly, your issue was a loader problem of windows:
> mono.exe is dynamically linked to gc.dll, but if the loader finds the
> mercury gc.dll in the path (maybe it was in the current directory?)
> it tryed to load that, but mono.exe couldn't execute because the mercury
> gc.dll doesn't contain the garbage collector needed by mono.

Right.  The problem is that mono.exe references gc.dll with a weak name,
and Windows picks up the wrong version.

Of course since the gc.dll that Mono uses is a native code (unmanaged) DLL, 
and strong names only work for managed DLLs, you can't use strong names
to avoid that.  But if it were managed, then at least in theory you could...

I was just using this example to illustrate the point that name clashes
are not that uncommon.

> Since the gc.dll in mercury should be just an helper dll, I suggest
> renaming it to mercury-gc.dll or something like that: I think this is a
> good idea regardless of the name clash issues.

That's easier said than done.  The Mercury build system compiles each
Mercury module "foo" (in source file "foo.m") to "foo.dll".  The file
"gc.dll" comes from the Mercury standard library module named "gc".
It's not possible to rename that module, because that would break
compatibility with existing Mercury programs that refer to the module
by the name "gc" in their source code.

Actually I did find a work-around: run the program from a different
directory, so that Windows won't find gc.dll, but setting MONO_PATH
so that mono will find gc.dll.  But this is not very convenient.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.