microsoft / microsoft/WindowsAppSDK

File Pickers not functional in PartialTrust applications

Open
#3,536 4 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-File access
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

### 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](https://nicksnettravels.builttoroam.com/windows-ui-as-partial-trust/)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the packaged app scenario by changing the manifest entry point to Windows.PartialTrustApplication and removing the runFullTrust capability. Start at the WinRT Interop call to InitializeWithAppWindow.Initialize and compare the behavior with the related discussion #3447 and linked 2021 report. Done means identifying the responsible component and enabling file open/save pickers in partial-trust applications without E_ACCESSDENIED.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, desktop, operating-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.