hi,
I have a native c++ dll and i am trying to import a function of the class in the dll to use it in c# so i wrote a wrapper :
the prototype of function in the dll :
and finally in my c# code i call the wrapper but it gives an exception in the following line:
Exception is:
my c# code:
please help me.
I have a native c++ dll and i am trying to import a function of the class in the dll to use it in c# so i wrote a wrapper :
Code:
public struct myclassUnman{
public:
[DllImport("mydll.dll",
EntryPoint="??0myclass@@QAE@XZ",
CallingConvention=CallingConvention::ThisCall)]
static void ctor(myclassUnman*);
[DllImport("mydll.dll",
EntryPoint="??1myclass@@QAE@XZ",
CallingConvention=CallingConvention::ThisCall)]
static void dtor(myclassUnman*);
[DllImport("mydll.dll",
EntryPoint="?getboolvalue@myclass@@QAE_NPAEH@Z",
CallingConvention=CallingConvention::ThisCall)]
static bool getboolvalue(myclassUnman*,unsigned char*,int);
};
public ref class myclassWrap
{
public:
myclassWrap(){
tv = new myclassUnman();
myclassUnman::ctor(mu);
}
~myclassWrap(){
myclassUnman::dtor(mu);
}
bool getboolvalue(unsigned char* a,int b){
return myclassUnman::getboolvalue(mu,a,b);
}
private:
myclassUnman *mu;
};
Code:
public: bool __thiscall myclass::getboolvalue(unsigned char *,int)
Code:
return myclassUnman::getboolvalue(tv,a,b);
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Code:
unsafe
{
myclassWrap mw = new myclassWrap();
Console.WriteLine(mw.getboolvalue((byte*)11, 2));
}