ewang1205
asked on
A call to PInvoke function unbalanced the stack.
I got this error when running the following code:
A call to PInvoke function 'tonin_image!tonin_image.F orm1::Shel lExecute' 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.
Public Class Form1
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles a.Click
Dim HttpJump
Dim MyUrl As String
MyUrl = "http://server/default.aspx?lease=" + a.Text + "&file_sufx=" + File_Sufx.Text
ShellExecute(0, "", MyUrl, "", "", vbNormalFocus)
End Sub
End Class
A call to PInvoke function 'tonin_image!tonin_image.F
Public Class Form1
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles a.Click
Dim HttpJump
Dim MyUrl As String
MyUrl = "http://server/default.aspx?lease=" + a.Text + "&file_sufx=" + File_Sufx.Text
ShellExecute(0, "", MyUrl, "", "", vbNormalFocus)
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Convert all "Long" to "Integer" and you should be good to go:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Integer, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Integer) As Integer