Allen G
12-23-2004, 10:15 PM
I'm seriously about to pull my hair out. I've been trying for hours to get this thing to work.
What I'm doing
Doing a folder browse operation from a Context Menu on the same form.
Private Sub Playlist_FolderAdd(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem8.Click
Dim b As New FolderBrowserDialog
b.Description = "Select a folder containing media."
b.ShowNewFolderButton = False
b.RootFolder = Environment.SpecialFolder.Desktop
If b.ShowDialog = DialogResult.OK Then
Debug.WriteLine(b.SelectedPath)
End If
End Sub
Exception Thrown:
System.Runtime.InteropServices.SEHException: External component has thrown an exception.
at System.Windows.Forms.Shell32.SHBrowseForFolder(BROWSEINFO lpbi)
at System.Windows.Forms.FolderBrowserDialog.RunDialog(IntPtr hWndOwner)
at System.Windows.Forms.CommonDialog.ShowDialog()
at Shock.frmMain.Playlist_FolderAdd(Object sender, EventArgs e) in E:\Shock\Shock\Dialogs\frmMain.vb:line 1886
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Command.DispatchID(Int32 id)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativ eMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Shock.SubMain.Main() in E:\Shock\Shock\SubMain.vb:line 27
What is very weird is, I put this same exact code in the form load for instance, it'll throw the exception. But if I try the code in another project, works perfectly fine. Could this be a threading issue, some how? Even though everything is called form the same form.
What I'm doing
Doing a folder browse operation from a Context Menu on the same form.
Private Sub Playlist_FolderAdd(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem8.Click
Dim b As New FolderBrowserDialog
b.Description = "Select a folder containing media."
b.ShowNewFolderButton = False
b.RootFolder = Environment.SpecialFolder.Desktop
If b.ShowDialog = DialogResult.OK Then
Debug.WriteLine(b.SelectedPath)
End If
End Sub
Exception Thrown:
System.Runtime.InteropServices.SEHException: External component has thrown an exception.
at System.Windows.Forms.Shell32.SHBrowseForFolder(BROWSEINFO lpbi)
at System.Windows.Forms.FolderBrowserDialog.RunDialog(IntPtr hWndOwner)
at System.Windows.Forms.CommonDialog.ShowDialog()
at Shock.frmMain.Playlist_FolderAdd(Object sender, EventArgs e) in E:\Shock\Shock\Dialogs\frmMain.vb:line 1886
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Command.DispatchID(Int32 id)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativ eMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Shock.SubMain.Main() in E:\Shock\Shock\SubMain.vb:line 27
What is very weird is, I put this same exact code in the form load for instance, it'll throw the exception. But if I try the code in another project, works perfectly fine. Could this be a threading issue, some how? Even though everything is called form the same form.