[Mono-osx] DllExceptionNotFound When using p/invoke on OSX

dman1264 dman at nycap.rr.com
Thu Nov 18 10:28:46 EST 2010


Hello 
I am trying to call unmanaged code from managed c# code by using p/invoke. 

I have the following dllimport attribute in my managed DLL

[dllimport("UnMan")]
public static extern in CalcExampleSum(int a, int b);

I have a console app which references this managed dll
the code is as follows

static Void Main(String args[])
{
int a= 25;
int b=34;
int total=0;
total= NativeMethods.CalcExampleSum(a,b);

System.Console.Writeline("The Sum is:{0}",total);
System.console.Readline();
}

I created my libUnMan.dylib in xcode the code follows

UnMan.h

extern "C"
{
    int CalcExampleSum(int a ,int b);

}

UnMan.cp


extern "C"
{
     int CalcExampleSum(int a, int b)
     {     
    int total=0;
    total = a + b;
    return total; 
      }
}

 This code works on open SUSE. It builds on all platforms and runs on all
except Mac OSX so assume any syntax errors are transcription errors.
 Where do I have to put the dylib so that it is found?
 http://www.mono-project.com/Interop_with_Native_Libraries#Library_Handling
I have done the things listed at the page listed above.
I believe it is a search path problem I have put the libUnMan.dylib
everywhere trying to solve the problem still no luck.
I am open to all ideas!


-- 
View this message in context: http://mono.1490590.n4.nabble.com/DllExceptionNotFound-When-using-p-invoke-on-OSX-tp3048922p3048922.html
Sent from the Mono - OSX mailing list archive at Nabble.com.


More information about the Mono-osx mailing list