Can someone tell me why Im getting this error message?
VB Code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace Card_Test { public partial class Form1 : Form { [DllImport("cards.dll")] private static extern bool cdtInit(ref int width, ref int height); [DllImport("cards.dll")] private static extern bool cdtDraw(IntPtr hdc, int x, int y, int card, int mode, long color); private IntPtr hdc = new IntPtr(); public Form1() { InitializeComponent(); int iWidth = 100; int iHeight = 300; if (!cdtInit(ref iWidth, ref iHeight)) throw new Exception("cards.dll did not load"); } private void Form1_Load(object sender, EventArgs e) { } private void Form1_Paint(object sender, PaintEventArgs e) { //base.OnPaint(e); hdc = e.Graphics.GetHdc(); Draw(); e.Graphics.ReleaseHdc(hdc); } private void Draw() { cdtDraw (hdc, 35, 10, 1, 0, 0); } } }
VB Code:
PInvokeStackImbalance was detected Message: A call to PInvoke function 'Card Test!Card_Test.Form1::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.


Reply With Quote
