简体   繁体   English

WPF Desktop Bridge 进程外后台任务无法访问 Documents 文件夹

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

I'm developing a WPF (Desktop Bridge) application that performs some logic on startup and in out-of-process background task.我正在开发一个 WPF(桌面桥接器)应用程序,它在启动和进程外后台任务中执行一些逻辑。 This logic creates and uses a file in the user's Documents folder.此逻辑在用户的 Documents 文件夹中创建并使用一个文件。

I've created out-of-process BG task in WPF (Desktop Bridge) application according to the article on Microsoft Developer Blog: Link我根据 Microsoft Developer Blog 上的文章在 WPF(桌面桥接)应用程序中创建了进程外 BG 任务: 链接

To use the Documents folder, I've added the appropriate permission to the manifest of Package project:为了使用 Documents 文件夹,我在 Package 项目的清单中添加了适当的权限:

<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.但是,不幸的是,BG 任务中调用KnownFolders.DocumentsLibrary.CreateFolderAsync("SubfolderName", CreationCollisionOption.OpenIfExists)方法导致异常: 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. WPF应用程序代码中相同逻辑的调用成功。 Adding the same permissions to the BackgroundTaskWrapper (UWP) project doesn't solve the problem.向 BackgroundTaskWrapper (UWP) 项目添加相同的权限并不能解决问题。

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).任务仅在 Windows 2004 上正常运行。它不适用于以前版本的 Windows:1909、1903、1809、1709(由于项目的目标版本,未在旧版本上测试)。

Sample: Github示例: Github

WPF Desktop Bridge out-of-process background task cannot access Documents folder WPF Desktop Bridge 进程外后台任务无法访问 Documents 文件夹

During the testing, it could create text.bgtxt file successfully within background task in my environment (os version 2004).在测试过程中,它可以在我的环境(操作系统版本 2004)的后台任务中成功创建 text.bgtxt 文件。 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).主要问题是还没有多少用户迁移到 2004 版本(我的应用程序在 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.所以目前的解决方法是使用图片库替换文档库。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在桌面桥中的WPF应用程序中执行进程内后台任务 - Can I do a in-process background task in a WPF app in Desktop Bridge 如何在WPF桌面应用程序中开发允许从另一个.NET桌面应用程序进行进程外自动化的公共API对象模型 - How to Develop a Public API Object Model In a WPF Desktop Application That Allows For Out-Of-Process Automation From Another .NET Desktop Application 使用 TPL 和进程外 COM 服务器的 C# WPF 应用程序的奇怪问题 - Strange issue with C# WPF app using TPL with an out-of-process COM server .NET Core WPF Desktop Bridge - 桌面快捷方式/任务栏快捷方式绕过检查更新 - .NET Core WPF Desktop Bridge - Desktop Shortcuts / Task Bar Shortcuts Bypasses Check For Updates 在Desktop Bridge下运行时,无法访问输出目录中的文件 - Cannot access files in output directory when running under Desktop Bridge 在Desktop Bridge下获取真实的appdata文件夹 - Getting the real appdata folder under Desktop Bridge WPF Desktop Bridge App作为Chrome本地消息传递主机 - WPF Desktop Bridge App as chromium native messaging host 带有 WPF 桌面桥包的 UWP 中的 System.BadImageFormatException - System.BadImageFormatException in UWP with WPF desktop bridge package 如何使用 XamlIslands 和桌面桥 package 和 WPF (.NET Core) 应用程序? - How to package a WPF (.NET Core) app with XamlIslands and Desktop Bridge? 使用Desktop Bridge时,附属组件从包装中剥离 - Satellite assemblies stripped out of package when using Desktop Bridge
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM