Check the calling conventions you are using.
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
Reference to other related question: Callback from C function - crash
jdehaan
2009-09-23 10:37:11
Check the calling conventions you are using.
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
Reference to other related question: Callback from C function - crash
Problem solved unexpectedly my myself (after 5 hours googling). I suspected a wrong calling convention already, but I didn't know how to switch it correctly. I've changed it in the C code as suggested here (http://computerarts.com.cn/dotnet-tech/1691/):
// GPCallback
/////////////
//__declspec(dllexport) typedef void (* GPCallback)(
//typedef __declspec(dllexport) void (* GPCallback)(
typedef void (_stdcall * GPCallback)(
GPConnection * connection,
void * arg,
void * param
);