ShellFileDialogs
ShellFileDialogs copied to clipboard
Unexpected HRESULT: 0x0000 returned from IModalWindow.Show(...)
I always get this error when using your library, regardless of the function used (open a folder, open a file...). Tests were done with the demo program. The cancel works very well.
System.Runtime.InteropServices.ExternalException
HResult=0x00000000
Message=Unexpected HRESULT: 0x0000 returned from IModalWindow.Show(...).
Source=ShellFileDialogs
StackTrace:
at ShellFileDialogs.Utility.ValidateDialogShowHResult(HResult dialogHResult) in C:\Users\Marc\Documents\ShellFileDialogs\ShellFileDialogs\Utility.cs:line 212
at ShellFileDialogs.FolderBrowserDialog.ShowDialogInner(IFileOpenDialog dialog, IntPtr parentHWnd, String title, String initialDirectory) in C:\Users\Marc\Documents\ShellFileDialogs\ShellFileDialogs\Dialogs\FolderBrowserDialog.cs:line 63
at ShellFileDialogs.FolderBrowserDialog.ShowDialog(IntPtr parentHWnd, String title, String initialDirectory) in C:\Users\Marc\Documents\ShellFileDialogs\ShellFileDialogs\Dialogs\FolderBrowserDialog.cs:line 19
at ShellFileDialogs.Demo.Program.Main(String[] args) in C:\Users\Marc\Documents\ShellFileDialogs\ShellFileDialogs.Demo\Program.cs:line 17
Doing some debugging, I saw TryGetWin32ErrorCode always returns false. The condition if( GetFacility( hr ) == HResultFacility.Win32 ) (l.142) always returns false.
Framework target : .NET 4.8
The reason for the error is simple. When the HResult returns a success value, it is 0. The bitwise operation performed in GetFacility will therefore always return zero. TryGetWin32ErrorCode should return true if 0 <= hr.
I'm unable to reproduce the issue at my end - can you please post a simple minimal project that reproduces the issue?
Of course! ShellFileDialogsDemo.zip
It is a build made directly after git-clone (Merge branch 'dev/2021-04-nullable'). The only difference is that the assembly has not been signed.
ShellFileDialogs target framework: net48 Demo target framework: net48 IDE: Visual Studio 2022 Test Environment: Windows 10 Professional (21H2 - 19044.1741)
Thanks - I can repro it in the ShellFileDialogs.Demo.exe - curious...
I'll look at this this weekend.
Any updates on this issue?
I wanted to try the nuget package. So for now I will just try to use the source code.
A pull request to resolve this issue has been suggested: https://github.com/Jehoel/ShellFileDialogs/pull/4.
Otherwise, there is a fork that integrates this fix and a support for selecting multiple folders: https://github.com/Profy/ShellFileDialogs
Already found it. Works very well. Thanks
Also hitting this issue. Any update ?