[Mono-list] DllImport - what's wrong

Jerzy Bartuszek koxta@koxta.net
Thu, 28 Apr 2005 02:03:42 +0200 (CEST)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there... I'm trying to import a dll I've created from scratch - using
nasm and then dllwrap. However, I still get this exception:

koxta@limbo csharp $ mono main.exe

Unhandled Exception: System.DllNotFoundException: Add.dll
in (wrapper managed-to-native) Whatever:Add (int,int)
in <0x0000f> Whatever:Main ()

Here are the files:

koxta@limbo csharp $ cat main.cs
using System;
using System.Runtime.InteropServices;

public class Whatever {

        [DllImport("Add.dll")]
        public static extern int Add(int a, int b);

        public static int Main() {

                Console.WriteLine("Your sum: {0}", Add(2,3));

                return 0;
        }
}

koxta@limbo csharp $ cat Add.asm
segment .text
        global _Add

_Add:
        push ebp
        mov ebp, esp
        mov eax, 0
        add eax, [esp+8]
        add eax, [esp+12]
        pop ebp
        ret 8

Here's what I do:

nasm -f elf -o Add.o Add.asm -l Add.lst (I tried -f win32 and -f coff too).
echo "EXPORTS Add" > Add.def
dllwrap --mno-cygwin --target i386-mingw32 --def Add.def
- --export-all-symbols Add.o -o Add.dll
mcs main.cs
mono main.exe

Please, any help would be appreciated

Regards,

Jurek 'Koxta' Bartuszek

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCcChe6l8uJkeTVlMRAqtZAJ9koUtTnuPXXsizmmp3MWusSdkvrQCdEZOP
nGMz6S+AES1ShsjYATwr3sM=
=hIK2
-----END PGP SIGNATURE-----