Home All Groups Group Topic Archive Search About

FolderBrowserDialog bug in .NET 2.0 x64 Systems

Author
29 Dec 2006 7:52 PM
LPJJ
I can confirm there is a problem with FolderBrowserDialog.ShowDialog() method
on 64 bits computers (XP or Vista). Many times calling that method reports
the following exception:

System.Runtime.InteropServices.SEHException: External component has
thrown an exception.
   en
System.Windows.Forms.UnsafeNativeMethods.Shell32.SHBrowseForFolder(BROWSEINFO
lpbi)
   en System.Windows.Forms.FolderBrowserDialog.RunDialog(IntPtr hWndOwner)
   en System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
   en hc.e(Object A_0, EventArgs A_1)
   en System.Windows.Forms.Control.OnClick(EventArgs e)
   en System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   en System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
   en System.Windows.Forms.Control.WndProc(Message& m)
   en System.Windows.Forms.ButtonBase.WndProc(Message& m)
   en System.Windows.Forms.Button.WndProc(Message& m)
   en System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   en System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Sometimes the exception is raised just when the "browse for folder" window
is opened, sometimes while navigating through the folder tree, sometimes it
is not raised at all, so I could not be able to find the direct cause...

To raise the exception just do:
FolderBrowserDialog  folderBrowserDialog1=new FolderBrowserDialog();
folderBrowserDialog1.ShowNewFolderButton=true;
folderBrowserDialog1.SelectedPath=textBoxFolder.Text;
if (folderBrowserDialog1.ShowDialog()==DialogResult.OK)
{
    textBoxFolder.Text = folderBrowserDialog1.SelectedPath;
}

This is a serious problem affecting 64 bits systems, does someone know a
workaround for this, or a bugfix from Microsoft?

I can provide easily a full memory dump is someone at Microsoft wants to
review this.

Thanks

AddThis Social Bookmark Button