[Mono-list] Dll loading failure

Timothy Graupmann tgraupmann@yahoo.com
Thu, 28 Apr 2005 07:47:44 -0700 (PDT)


Try putting dodaj.dll in the same directory as your exe.

Here is the compile script I use that includes a dll.
http://cvs.sourceforge.net/viewcvs.py/tagelflax/tagml/vc%237/CompileWithMonoConsole.cmd?rev=1.5&view=markup

You just need this:
-r "dodaj.dll"

--- Jurek Bartuszek <koxta@koxta.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi!
> 
> What do I have to provide in order to load a dll in C# (mono/mcs)?
> 
> This piece of code has been compiled using mcs.
> 
> using System;
> using System.Runtime.InteropServices;
> 
> public class Hello {
> 
>         [DllImport("dodaj.dll")]
>         public static extern int Add(int a, int b);
> 
>         public static int Main() {
> 
>                 Console.WriteLine("Your sum: {0}", Add(2,3));
> 
>                 return 0;
>         }
> }
> 
> Executed on windows, dodaj.dll is being found and a result of 5 is being
> displayed. However, when I run `mono main.exe` on Linux, I still keep
> getting this exception:
> 
> $ mono main.exe
> 
> Unhandled Exception: System.DllNotFoundException: dodaj.dll
> in (wrapper managed-to-native) Hello:Add (int,int)
> in <0x0000f> Hello:Main ()
> 
> Is there any system variable that should be set, or else?
> 
> Regards,
> 
> Jurek Bartuszek
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFCcPSh6l8uJkeTVlMRAuL+AJ4mWO59j+Cr6p6CpGQM7ijxelPamwCgxiQO
> 3ni/q1sXEJ8X+Vtoh0tsANo=
> =XSpp
> -----END PGP SIGNATURE-----
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com