Hi there,

My application, which uses the FolderBrowserDialog, sometimes throws a
NullReferenceException with the following call stack when calling
FolderBrowserDialog.ShowDialog():

at
System.Windows.Forms.UnsafeNativeMethods.Shell32.SHBrowseForFolder(BROWSEINFO
lpbi)
at System.Windows.Forms.FolderBrowserDialog.RunDialog(IntPtr hWndOwner)
at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
...

Any ideas what could be causing this?

Thank you!

Re: NullReferenceException from FolderBrowserDialog by Scott

Scott
Tue Apr 22 19:29:05 CDT 2008

It is most likely caused when no file is selected and the OK button is
pressed or when the cancel button is pressed. You must code for these two
possibilities.

-Scott

"ondrej421" <ondrej421@discussions.microsoft.com> wrote in message
news:21C3547F-FE12-41DE-AC89-94EE8C5DAF89@microsoft.com...
> Hi there,
>
> My application, which uses the FolderBrowserDialog, sometimes throws a
> NullReferenceException with the following call stack when calling
> FolderBrowserDialog.ShowDialog():
>
> at
> System.Windows.Forms.UnsafeNativeMethods.Shell32.SHBrowseForFolder(BROWSEINFO
> lpbi)
> at System.Windows.Forms.FolderBrowserDialog.RunDialog(IntPtr hWndOwner)
> at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
> ...
>
> Any ideas what could be causing this?
>
> Thank you!