Skip to content

File Pickers not functional in PartialTrust applications #3536

@zsolt3991

Description

@zsolt3991

Describe the bug

During migration of a UWP application to Windows App SDK it was noticed that File Pickers are not functional when using an AppContainer style app instead of a Full Trust application when packaged.

It is not clear which component in the dependency chain is actually responsible, opening the bug here on the premise of UI not being at fault since its a system dialog an not WinUI dialog. The exception happens in the WinRT Interop call and not user code.

This behavior is present since Project Reunion releases from 2 years ago, see the second linked post in the additional contents and does not seem like a recent regression.

Steps to reproduce the bug

  1. Create a sample application project
  2. Add File Open/Save picker following the Documentation for WinUI3/Win App SDK on Interop
  3. Run the application and verify it works
  4. Go into Package Manifest and change Entrypoint to => Windows.PartialTrustApplication and remove the runFullTrust restricted capability.
  5. Build and Run the application again
  6. Application will crash on trying to open the picker with Win32 Exception E_ACCESSDENIED in the call for InitializeWithAppWindow.Initialize()

Expected behavior

Application is able to open File Picker in partial trust mode.

This is base functionality that is possible in UWP which blocks the migration path of applications that perform any file I/O requiring user choice. In some cases running full trust is not allowed only by exemption from the rule, see Microsoft Store submission guidelines.

Screenshots

No response

NuGet package version

Windows App SDK 1.2.5: 1.2.230313.1

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

See links below:

Similar report in discussions: #3447
Post from 2021 with the issue on Project Reunion

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-File accessTopics related to Microsoft.Windows.Storage.Pickers APIs for selecting files/folders etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions