[Mono-list] Can't get a simple shared object to be used - DllNotFoundException

Jonathan Pryor jonpryor at vt.edu
Wed Jul 31 02:33:40 UTC 2013

On Jul 30, 2013, at 5:34 PM, Stifu <stifu at free.fr> wrote:
> I've never done that myself, but if I remember correctly, you're not supposed to add the ".so" part. Just do [DllImport("libshared")].

Close; you should prefer [DllImport("shared")], with one exception. On Windows, this will try to load SHARED.DLL, on Linux it will load libshared.so, and on OS X it will load libshared.dylib.

The exception is that if the library name contains a '.', Windows LoadLibrary() will not automatically append a .DLL extension, so this would always fail:


In these cases, you should use the full Windows filename, and provide a .dll.config file so that the file can be found on other platforms:


- Jon

More information about the Mono-list mailing list