microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.27k stars 674 forks source link

FileOpenPicker, FolderPicker and FolderPicker not available in partial trust/AppContainer #9557

Open sungaila opened 4 months ago

sungaila commented 4 months ago

Describe the bug

In WinUI 3 it is needed to do the following call to initialize a picker dialog:

WinRT.Interop.InitializeWithWindow.Initialize(openPicker, hWnd);

It works just fine in full trust mode but fails when it is called in partial trust/inside an AppContainer (access denied exception).

This is terrible news because it means that WinUI 3 can either use the WinRT file dialogs OR run in partial trust. But NOT both at the same time.

Steps to reproduce the bug

  1. Create a packaged WinUI 3 app with the default template
  2. Change Package.appxmanifest such that the app runs in partial mode
  3. Optional: add the broadFileSystemAccess capability
  4. Test the FilePicker code snippet from the WinUI 3 Gallery: winui3gallery://item/FilePicker

Expected behavior

The file dialogs should open just as expected.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.5.2: 1.5.240404000

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

github-actions[bot] commented 4 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Rybasum commented 4 months ago

This issue is several years old and it looks like Microsoft simply does not want us to put non-UWP apps in AppContainer. Otherwise they would realize that most UI apps use file open/save pickers. AppContainer? yes, sure, but no file open/save. Very strange. Honestly, they should simply document this and not make developers waste their time.

sungaila commented 4 months ago

@Rybasum The documentation part is kinda confusing. There is in-depth documentation on how to put your WPF, WinForms or WinUI 3 app into an AppContainer using MSIX. Yet something fundamental like selecting files isn't possible with Win32 or WinRT APIs.

I have a simple WinUI 3 app here where the user selects a file and more information is put into a DataGrid. You'd think that it would be a perfect candidate for partial trust/AppContainer and just the filesystem capability.

mominshaikhdevs commented 1 month ago

@sungaila you want to see

https://github.com/microsoft/WindowsAppSDK/issues/8#issuecomment-2256000803

and https://github.com/microsoft/WindowsAppSDK/issues/219

and the win32-app-isolation repo.