Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The FileOpenPicker's method PickSingleFileAsync throws ComException #5214

Closed
alexdi220 opened this issue Jun 18, 2021 · 4 comments
Closed

The FileOpenPicker's method PickSingleFileAsync throws ComException #5214

alexdi220 opened this issue Jun 18, 2021 · 4 comments
Labels
product-winui3 WinUI 3 issues team-Reach Issue for the Reach team

Comments

@alexdi220
Copy link
Contributor

Describe the bug
Hi, just tried to pick an image but got an exception - System.Runtime.InteropServices.COMException: 'Invalid window handle. (0x80070578)' To reproduce try the following code.

Steps to reproduce the bug

            FileOpenPicker filePicker = new FileOpenPicker();
            foreach(string ext in new []{ ".jpeg", ".jpg", ".png", ".bmp" }) 
                filePicker.FileTypeFilter.Add(ext);
            
            filePicker.ViewMode = PickerViewMode.Thumbnail;
            filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            filePicker.SettingsIdentifier = "ImageFilePicker";
            filePicker.CommitButtonText = "Insert";

            StorageFile file = await filePicker.PickSingleFileAsync(); //throws exception

Expected behavior

Screenshots

Version Info

NuGet package version:

[WinUI 3 - Project Reunion 0.5: 0.5.7]

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
Insider Build (xxxxx)
October 2020 Update (19042)
May 2020 Update (19041) Yes
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jun 18, 2021
@jaigak
Copy link
Contributor

jaigak commented Jun 18, 2021

You need to cast the picker to IInitializeWithWindow and call it's Initialize with the window handle to use it in a desktop app.

@Marv51
Copy link
Contributor

Marv51 commented Jun 18, 2021

See #2716

@StephenLPeters StephenLPeters added team-Reach Issue for the Reach team product-winui3 WinUI 3 issues labels Jun 18, 2021
@StephenLPeters
Copy link
Contributor

https://docs.microsoft.com/en-us/uwp/api/windows.storage.pickers.fileopenpicker.-ctor?view=winrt-19041#remarks

@StephenLPeters StephenLPeters removed the needs-triage Issue needs to be triaged by the area owners label Jun 18, 2021
@alexdi220
Copy link
Contributor Author

Thanks all for the answers. But it still looks like a bug. The WA is ok but believe should be fixed in the future versions.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jun 21, 2021
@akilarajesh1313 akilarajesh1313 removed the needs-triage Issue needs to be triaged by the area owners label Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product-winui3 WinUI 3 issues team-Reach Issue for the Reach team
Projects
None yet
Development

No branches or pull requests

5 participants