c++ - C# : DLLImport - DLL Not Found exception -


suppose want call c++ functions c# code, having following problem:

case 1:

class abc { private :     int ;  public :     int  getvalue()     {         return 100;     } };  int getcounter() {     abc* p = new abc();      int = p->getvalue();     return i; } 

this case when calling function c# throws me dll not found exception.

case 2:

int getcounter() {     int = 333;     return i; } 

the case when calling function c# works fine.

any ideas why? how can fix it?

use sample line of code in cpp project (mathfuncsdll.h)

extern "c" __declspec(dllexport) double add(double a, double b); extern "c" __declspec(dllexport) double sub(double a, double b); extern "c" __declspec(dllexport) double mul(double a, double b); extern "c" __declspec(dllexport) double div(double a, double b); 

in c# code use

 [dllimport("mathfuncs.dll", callingconvention = callingconvention.cdecl)]  public static extern double add(double a, double b);   [dllimport("mathfuncs.dll", callingconvention = callingconvention.cdecl)]  public static extern double mul(double a, double b);   [dllimport("mathfuncs.dll", callingconvention = callingconvention.cdecl)]  public static extern double sub(double a, double b);   [dllimport("mathfuncs.dll",callingconvention = callingconvention.cdecl)]  public static extern double div(double a, double b);   [dllimport("mathfuncs.dll",callingconvention = callingconvention.cdecl)]  public static extern double bat(double a, double b); 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -