Shell Execute VB Error Message - Unbalanced Stack
Posted on 2007-03-22
I am trying to open a doc file using a VB application.
The code I am using is as below:
Public 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
ShellExecute(0&, "Open", "MyFileName.doc", CommandLine, vbNullString, 1)
i end up in getting the error message "A call to PInvoke function 'SampleWorkFlowAppln!SampleWorkFlowAppln.Form1::ShellExecute' 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."
Any suggestions on what could be wrong?