I am trying to call a C++ wrapper function from dotnet service on Linux the first time.
C++ code:
extern "C" std::string myfunc(int a, int b){
std::string mystring = funcB(a, b);
return mystring;
}
c# code:
public string myCsharpFunc getA(int a, int b){
return callMyFunc(a, b);
}
[DllImport("xxxx.so", EntryPoint ="myfunc", CallingConvention= CallingConvertion.Cdecl)]
private static extern string callMyfunc(int a, int b);
The dotnet service is running fine and I am able to do a test GET. I could also run into myFunc and the return from funcB looked correct. But everything crashed when mystring is returned with a segmentation fault (core dump). It seems like even if I made mystring returned as "test", the program crashed the same way. What did I miss?