I\'m making a C# application which is using GameSpy C code (the GP part). The C code is calling a callback (which is C# code) succesfully, but I get this error Run-Tim
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
);