How to solve error A call to PInvoke function MyMethod has unbalanced the stack.

Today I upgraded a C# program from .NET 2.0 to .NET 4.0 and started debugging it.

I got the error message when pInvoke called a C++ function in one of my DLLs:

Continue reading “How to solve error A call to PInvoke function MyMethod has unbalanced the stack.”