https://bugs.winehq.org/show_bug.cgi?id=50042
--- Comment #8 from Bruni earns.61@gmail.com --- Nikolay
What say?
GetExceptionForHR is a way to convert HRESULT error into an exception. Exceptions propagate through stack up to the entry point until some code catches them.
Microsoft implies the aim of GetExceptionForHR is to create exceptions that are not to be caught. See https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.m...
This bug means the absence (or unfitness) of a catch block.
Microsoft do not seemingly specify any GetExceptionForHR call in winforms\Managed\System\WinForms\FileDialog_Vista.cs as well. See https://referencesource.microsoft.com/#system.windows.forms/winforms/Managed... This is how SetFileTypes looks on that page:
private void SetFileTypes(FileDialogNative.IFileDialog dialog) { FileDialogNative.COMDLG_FILTERSPEC[] filterItems = FilterItems; dialog.SetFileTypes((uint)filterItems.Length, filterItems); if (filterItems.Length > 0) { dialog.SetFileTypeIndex(unchecked((uint)filterIndex)); } } }
So it seems native .NET gets by without a marchaled (and uncatchable) exception in SetFileTypes.
There may always be something left out of account but some explanation of `throw Marshal.GetExceptionForHR((int)hr);` is needed.