There is a discrepancy between CallingConvention.Cdecl and __stdcall. Try using the same convention.
Callback C++ dll -> C#: Run-Time Check Failure #0
Markus Forrer
21
Reputation points
In my project I have a .net core 3.1 C# app and an unmanaged C++ dll. From the C++ dll I want to implement a callback. The callback works only once, then I get the error 'Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call'.
Thanks for any hints
Developer technologies | C#
11,578 questions
Accepted answer
1 additional answer
Sort by: Most helpful
-
Markus Forrer 21 Reputation points
2021-04-20T04:20:13.693+00:00 Thank you for your answer.
I changed the 3 __stdcall to __cdecl and now it works better (about 1 minute). After that I get the following error message on the line '_observer(message);': An unhandled exception of type 'System.ExecutionEngineException' occurred in Unknown Module.