DEBUG Error Symptom alert run-time Check Failure #0-the value of ESP is not properly saved across a function call. This was usually a result of calling a function declared with one calling convention with a function pointer declared with A different calling convention release version of the application disappears without any information. C # and C + + both explicitly define __stdcall as the function calling convention, but debug version debugging still prompts the above phenomenon, the effect is that the callback function of the calling convention is inconsistent. The troubleshooting is not the calling convention inconsistency, but the parameter of the callback function is inconsistent, causing the callback function to release the stack memory is an exception. The callback function in the C++dll Library defines typedef void (CALLBACK *prhmessagecallback) (int ivk_value, int iflag, void* puserdata); This should be the correct definition in C #:
[Unmanagedfunctionpointer (Callingconvention.stdcall)]
public delegate void Prhmessagecallback (int ivk_value, int iflag, IntPtr userData);
and cannot be defined as
[Unmanagedfunctionpointer (Callingconvention.stdcall)]
public delegate void Prhmessagecallback (int ivk_value, int iflag, object userData);
C # calling C++dll Library calling convention issues