Saturday, December 17, 2011

The filepicker was unexpectedly closed by Windows

I don't know how this started but this error was occurring whenever I try to use Open (common dialog in Windows) command in any application. I first encountered this error when I was downloading a file from my email account and want to save it on my computer. When the time comes to show the dialog to save the file, this error popped up.

Here is its text:
The filepicker was unexpectedly closed by Windows.
(There wasn't any text as message in the dialog box, error message was only showed in the title bar.)

The programs could be Firefox, Notepad, Google Chrome or anything else whichever is using the Open Common Dialog of Windows OS to open a file.

First, I searched on internet to find a solution to this problem but nothing was seeming to work for me. Only 1 solution, I think, should work was to fix the MRU (Most Recently Used) list of Open dialog by editing the registry. Because the problem could have been arose of a path in MRU which is missing on the hard disk. But everything was in Hex codes. So I cancelled to mess with the registry. Then I thought the error would not arise if a path is missing because I must have opened a document (using any app's Open command) from one location and deleted it and then used Open command again; and this wasn't causing any error.

Then I opened Notepad and clicked on the Open command the Notepad crashed and gave me 3 options :
  1. Check online for solution (I clicked it but no solution found which happens in most of case)
  2. Close the application (most of people would do this)
  3. Debug the application
I first tried 2nd option then 1st and then decided to debug it!
I opened it to debug in Visual Studio 2008 and found that there is some problem with the comdlg32.dll file which is used by most of programs to show the Open Common Dialogbox to open files in them. So ultimately I concluded that the comdlg32.dll file must become corrupt. However there was no error occurring for the Save Common Dialogbox (I didn't checked other common dialogs: Color, Font and Print).

So, now I need to replace the corrupted comdlg32.dll with a fine version of it. The problem may get solved just by downloading that file from a DLL download website but it is risky. See here, how it could be risky.

Windows provides System File Checker (SFC) utility [Windows 98 and all later OS vers.] which checks for corrupted windows files and can replace with original files from the Windows's DLL cache or from the Windows installation disk.

So I opened the command prompt with Administrator rights and issued SFC /SCANNOW command. It checked for all system files and generated a log. I checked the log file and at the end of it, I found that SFC has considered the comdlg32.dll as corrupt.

At the end of the scan process, it showed a message that some files are corrupt but it can not replace them now, a system restart was needed. I restarted my computer and when it was shutting down, the comdlg32.dll file get replaced when the system was displaying message similar to "Please wait... Windows is installing updates.".

After the restart the Open command was working fine.