[Mono-list] Dll loading failure

Jonathan Pryor jonpryor@vt.edu
Thu, 28 Apr 2005 15:46:23 -0400


On Thu, 2005-04-28 at 19:11 +0200, Michal Moskal wrote:
> On 4/28/05, Jurek Bartuszek <koxta@koxta.net> wrote:
> > > Mono does not support native code DLLs from Windows when running on Linux.
> > Are you 100% sure about that?
> 
> No. Maybe some wine interop would do? I'm not an expert here.

I'm 100% sure that you can't load a Win32 DLL under Mono using the
normal DllImport mechanism.  Why?  Because Mono's DllImport
functionality is built on dlopen(3) and dlsym(3) (similar to LoadLibrary
() and GetProcAddress() on Win32) -- it's the native OS loader.
Linux/Unix doesn't support loading PE/COFF dynamic libraries into an ELF
address space -- the loader file formats differ.

That doesn't mean it's impossible.  You could modify mono's loader to
support PE/COFF binaries (non-trivial, but likely possible).  A more
practical approach would be to skip DllImport and manually do what
DllImport does for you -- dlopen/dlsym -- but using a library that
supports PE/COFF.  Wine would be the logical way to do this, though I
don't know how easy it would be to integrate Mono and Wine like this.

 - Jon