PInvokeStackImbalance in .NET 2.0 with Cards.dll

Dec 30 2005 9:49 AM
I'm working on a card game in C#, and I figured, why not use the cards.dll for the drawing. So I wrote a small wrapper class around it, and it worked(Under .NET 1.1).

So I proceeded to port most of the application to 2.0, and get it networked using
Remoting. However, when I start drawing, I get a PInvokeStackImbalance exception:

PInvokeStackImbalance was detected
Message: A call to PInvoke function 'ZweedsPesten!ZweedsPesten.CardsDll::cdtDraw' 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.

As the class worked under .NET 1.1, I took an example from Programmers Heaven using the DLL aswell, and it crashed aswell. I have no idea what the problem is. According to the MSDN, it's a stack corruption, which seems odd to me as it used to work.

My code can be found here: http://upload.toolmaker.nl/CardsDll1.cs

Toolmaker