C#调用C++ dll报错,找了半天才找到原因

错误信息如下

Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'D:\MyProject\C#\CSharpInvokeCpp.CSharpDemo\CSharpInvokeCpp.CSharpDemo\bin\Debug\CSharpInvokeCpp.CSharpDemo.vshost.exe'.

Additional Information: A call to PInvoke function 'CSharpInvokeCpp.CSharpDemo!CSharpInvokeCpp.CSharpDemo.CPPDLL::Sub' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

解决方案如下:

http://stackoverflow.com/questions/5602645/why-do-i-get-pinvokestackimbalance-was-detected-for-this-simple-example

你可能感兴趣的:(C#调用C++ dll报错,找了半天才找到原因)