I’ve got a COM object wtitten on c#, and i’m using it in a c++ dll.
In c++ the COM object is imported with #import derective
The problem is that when the call is made from a c++ dll to any function of the COM object i’m getting a runtime check error:
Run-Time Check Failure #0 – The value of ESP was not properly saved
across a function call. This is usually a result of calling a
function declared with one calling convention with a function pointer
declared with a different calling convention.
In the com object wrapper generated by c++ import directive, all functions are declared as __stdcall
OK, it looks like I have found the solution:
I have declated In/Out/MarshalAs attributes for all methods in the C# COM interface: