Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 解决方案

because regular C functions work differently than the Windows API functions; their "calling conventions" are different, meaning how they pass around parameters is different. (This was hinted at in the error.)

 

所以请在C#中 使用CallingConvention = CallingConvention.Cdecl),代码如下:

[DllImport("CommonNativeLib.dll", CallingConvention = CallingConvention.Cdecl)]

或者 在C++中:
extern "C" __declspec(dllexport) int __stdcall Add(int a, int b) ...
 
posted @ 2017-09-04 14:25  庞国明  阅读(553)  评论(0编辑  收藏  举报