[Mono-osx] Can't find dll:(

Paolo Molaro lupus at ximian.com
Tue Oct 10 08:51:25 EDT 2006


On 10/10/06 david1969 at itu.dk wrote:
> mcs *.cs -out:lidgren.dll -target:library
> 
> When I then attempt to access the dll with the following:
> 
> using System.Runtime.InteropServices;
> using System;
> 
> public class Test {
>   [DllImport("lidgren.dll"]
>   public static extern bool IsNullOrEmpty(string x);
> 
>   static void Main() {
>     bool result=IsNullOrEmpty("");
>     Console.WriteLine(result);
>   }
> }
> 
> by typing the following at the terminal:
> 
> mono Test.exe
> 
> I get the following:
> Unhandled exception: System.DllNotFoundException: lidgren.dll
> in (wrapper managed-to-native) Test:IsNullOrEmpty (string)
> in <0x0001c> Test:Main ()
> 
> Any ideas? Is the dll not compiled correctly? It's in the same directory
> as the .exe...

DllImport is for importing functions from a C shared library (.dylib or
.bundle on OSX), not managed assemblies (which happen to have the .dll
extension).

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better


More information about the Mono-osx mailing list