[Mono-osx] Can't find dll:(
Andreas Färber
andreas.faerber at web.de
Tue Oct 10 08:45:08 EDT 2006
Hi,
Am 10.10.2006 um 14:33 schrieb david1969 at itu.dk:
> I'm just attempting my first foray into the world of mono/c# on OS X.
>
> I have tried to compile the source of a network library into a dll
> with
> the following (which seems to work fine):
>
> 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...
You are mixing up concepts of native C and managed C# code... Your
library is compiled correctly, but the way you are trying to
reference it is for unmanaged libraries only. To reference a managed
assembly include the -r:yours.dll switch in the command line and use
the class as if it were in your "local" assembly to be compiled.
HTH,
Andreas
More information about the Mono-osx
mailing list