[Mono-list] DllImport and mono

ptr2009 ptrajkumar at gmail.com
Thu May 14 14:22:16 EDT 2009


hey all

   I am trying out the pinvoke functionality in mono.   I am using Mono 2.4
on vista.

When I run the application natively "ConsoleApplication.exe"  it works fine.

But when I run against mono using "mono ConsoleApplication.exe" I get the
following Exception

Unhandled Exception: System.DllNotFoundException: Adder
  at (wrapper managed-to-native) ConsoleApplication1.Program:AddTwoNumbers
(int,int)
  at ConsoleApplication1.Program.Main (System.String[] args) [0x00000]


The exe and the dll both reside in the same directory.  Am I missing
something obvious to get this to work ?


Adder.dll
________________________

extern "C"
{
	__declspec(dllexport)  int AddTwoNumbers(int x , int y)
	{
		return x + y;
	}
}
_____________________________

Managed consoleApplication.exe has 

[DllImport("Adder.dll")]
        static extern int AddTwoNumbers(int x , int y);

        static void Main(string[] args)
        {
            Console.WriteLine("Starting pinovke test");

            int z = AddTwoNumbers(34, 34);

            Console.WriteLine("pinovke test done {0}" , z);
        }
________________________________________________

-- 
View this message in context: http://www.nabble.com/DllImport-and-mono-tp23546167p23546167.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list