in c++ i have these below classes
class A
{
public:
int __thiscall check(char *x,char *y,char *z);
private:
B *temp;
};
class B
{
friend class A;
Public:
B();
B(string x,string y,string z);
~B();
private:
string x;
string y;
string z;
};
my dll method in c++ is like this
__declspec(dllexport) int __thiscall A::check(char *x,char *y,char *z)
{
temp=new B(x,y,z);
return 1;
}
code for B() constructor is below:
B::B(string x, string y,string z)
{
.......
}
below mentioned is my c# dll import
[DllImport("sour.dll", CallingConvention = CallingConvention.ThisCall, ExactSpelling = true, EntryPoint = "check")]
public static extern void check(IntPtr val,string x,string y,string z);
the c++ build went successful with out any errors, but when i call this method from c# using dll import method i am getting this below error when i am trying to assign memory for "temp" class pointer. Below mentioned is the error.
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Can any one please help on this. Thanks in advance.