1

I'm developing a WPF (Desktop Bridge) application that performs some logic on startup and in out-of-process background task. This logic creates and uses a file in the user's Documents folder.

I've created out-of-process BG task in WPF (Desktop Bridge) application according to the article on Microsoft Developer Blog: Link

To use the Documents folder, I've added the appropriate permission to the manifest of Package project:

<Capabilities>
    <uap:Capability Name="documentsLibrary" />
</Capabilities>

Also, I've added File Type Associations permission on the file type I'm going to create and open in Documents folder and Background Task declaration with General/System event task type.

But, unfortunately, the call of KnownFolders.DocumentsLibrary.CreateFolderAsync("SubfolderName", CreationCollisionOption.OpenIfExists) method in BG task results in exception: Access is denied..

Stack Trace:

at Windows.Storage.KnownFolders.get_DocumentsLibrary()
at *...

The call of the same logic in the code of WPF application is successful. Adding the same permissions to the BackgroundTaskWrapper (UWP) project doesn't solve the problem.

Task is working properly only on Windows 2004. It's not working on previous versions of Windows: 1909, 1903, 1809, 1709 (not tested on older versions, due to target version of project).

Sample: Github

  • During the testing, it could create `text.bgtxt` file successfully within background task in my environment (os version 2004). So problem only occurs in the old system version right? – Nico Zhu Oct 15 '20 at 13:27
  • @NicoZhu-MSFT That's right, this behavior reproduces in Win versions older than 2004. In 2004 itself everything is ok. – Illia Syvolovskyi Oct 15 '20 at 13:34
  • May the issue has fixed within Version 2004, please try to update your os to latest version, or use app's local folder to replace documentsLibrary. And have you tried place file type permission and documentsLibrary all in BackgroundTaskWrapper Package.appxmanifest? – Nico Zhu Oct 15 '20 at 13:43
  • @NicoZhu-MSFT The main problem is that not many users have migrated to version 2004 yet (my app has many users on 1809-1909). Also, the local folder is not suitable for me, as well as the publisher folder, because I need a folder that will be available to all applications. As I said in question, adding these two permissions to manifest of Wrapper project does not solve the problem. – Illia Syvolovskyi Oct 15 '20 at 13:56
  • I tried to make the folder in the picture library after add picture library capability, and it works, could you use Picture library to replace ? – Nico Zhu Oct 15 '20 at 14:19

1 Answers1

0

WPF Desktop Bridge out-of-process background task cannot access Documents folder

During the testing, it could create text.bgtxt file successfully within background task in my environment (os version 2004). And the problem has fixed in latest OS version. please try to update your os to latest version.

The main problem is that not many users have migrated to version 2004 yet (my app has many users on 1809-1909).

I tried to make the folder in the picture library after add picture library capability, and it works. So currently the work around is use picture library to replace documents library.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36