Q:

How to resolve 'PInvoke function has unbalanced the stack Error' in Windows Form Application?

I have a Windows application, which uses the Windows API method to Drag the Winform from Client Area. Now when I release the mouse button it gives me the error "A call to PInvoke function 'xThemes!xThemes.API::SendMessage' has unbalanced the stack."
This error does produced when .net version is 3.5 but produces when version is greater than 3.5.
CS Page:
 private void titlebar_MouseMove(object sender, MouseEventArgs e)
        {
            //Function for form dragging.
            if (this.WindowState != FormWindowState.Maximized)
            {
                if (MouseButtons.ToString() == "Left")
                {
                    API.ReleaseCapture();
                    API.SendMessage(this.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
                }
            }
        }

API class
//Windows API for resizing the window.
        [DllImport("user32.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern int SendMessage(IntPtr hWnd, uint Msg, int lParam, int wParam);

        [DllImport("user32.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool ReleaseCapture();

        [DllImport("user32.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool ShowWindow(IntPtr hWnd, int cmdShow);

A:

The change in API will fixed this error (Suggested by Hans Passant)...
//Windows API for resizing the window.
[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int SendMessage(IntPtr hWnd, uint Msg, long lParam, long wParam);

[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)]
public static extern bool ReleaseCapture();

[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)]
public static extern bool ShowWindow(IntPtr hWnd, int cmdShow);

