c#中:[DllImport("footDLL.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public extern static void sc();
c++dll中:extern"C" {
_declspec(dllexport) void __stdcall sc() {
A a(1, 2);
a.add();
ofstream fout;
fout.open("E:\test6.txt");
fout << "TRUE" << endl << a.gre();
fout.close();
system("pause");
}
}
其中头文件:
typedef struct {
int x[max_vertex_num][max_vertex_num];
string str[max_vertex_num];
double sd[max_vertex_num];
}s;
class A {
public:
A(int x, int y) {
this->x = x;
this->y = y;
}
void add() {
x = x + y;
}
int gre() {
return this->x;
}
private:
int x;
int y;
listnode *l;
s d;
//Mgragh g;
}
为什么dll中结构体s是x数组从一维数组编程二维数组后,c#调用dll函数出现“System.StackOverflowException”类型的未经处理的异常在 Route.exe 中发生 这种BUG,怎么解决?