桌面桥 UWP Windows.Services.Store;

Desktop Bridge UWP Windows.Services.Store;

我有一个 windows 商店 WPF 桌面桥应用编译为 4.6.1。我将免费提供该应用程序并允许在应用程序内购买。为此,我需要为 windows 商店服务使用 UWP API。

我也在使用新的桌面桥打包应用程序模板。

我想将 UWP API 与 WPF 项目分开,因此我为 UWP API 创建了一个单独的 dll 项目。我引用 System.Runtime.WindowsRuntime 和 Windows。使用商店示例中的基本代码。

我添加了从 WPF 应用程序到 UWP dll 的引用。

只要我引用 UWP dll,桌面桥打包应用就会 return 9805 错误和 1 警告。

其中一个错误(这是典型的)是

The .winmd file 'Windows.winmd' contains type 'Windows.Gaming.Input.Gamepad'. The use of the Windows namespace is reserved.

警告是

No implementation file was provided for the .winmd file 'OUTPUT DIRECTORY PATH\Windows.winmd'. To generate registration information in the app manifest, specify the 'Implementation' metadata on the .winmd reference item in the project file.

如果我直接添加对 WPF 的两个引用(System.Runtime.WindowsRuntime 和 Windows)并删除 UWP dll,我会得到同样的错误。

更新:已通过以下方式确认这是 Desktop Bridge 的问题:

Creating a new WPF App project.
Creating a new Windows Application Packaging Project and configure it to include the WPF project.
Build the WPF project.
Create an appx package and perform WACK tests. All Okay.
Add a reference to the C:\Program Files (x86)\Windows Kits\UnionMetadata\winmd
Add a reference to the C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll
Build the WPF project.
Trying to build the Packaging Project results in 9805 errors.

这是我关注的博客:https://blogs.windows.com/buildingapps/2017/01/25/calling-windows-10-apis-desktop-application/

有人知道这是怎么回事吗?

错误消息来自 WACK 测试

<TEST INDEX="54" NAME="Type name correctness" DESCRIPTION="Only system types can be in the Windows namespace and no types can be in the global namespace." EXECUTIONTIME="00h:00m:08s.46ms" OPTIONAL="FALSE">
    <MESSAGES>
      <MESSAGE TEXT="The Windows.ApplicationModel.StartupTaskState type in the Windows.winmd file is in the Windows namespace." />
      <MESSAGE TEXT="The Windows.ApplicationModel.PackageSignatureKind type in the Windows.winmd file is in the Windows namespace." />
      <MESSAGE TEXT="The Windows.ApplicationModel.PackageVersion type in the Windows.winmd file is in the Windows namespace." />

有人知道如何绕过它吗?

Visual studio 几天前安装了更新。

我针对 4.6.1 构建了一个新的 wpf 应用程序项目 添加一个新的 windows 打包项目并配置它。 我不再收到一长串错误,而且参考资料似乎有效。两个应用程序编译。

所以我不确定之前出了什么问题,也不确定为什么修复了。

在桌面桥应用程序中使用 Windows.Services.Store 命名空间与 Windows 应用程序打包项目不兼容。在构建打包项目时,它将执行 WACK 测试,这将抛出 9805 错误并停止创建 appx 包。

如果您执行 WACK 测试,手动创建包仍然会出现 9805 错误。但至少你应该有一个可以提交给商店的应用程序。

Visual Studio 更新 15.5 包括对桌面桥打包项目的更新,允许您包含 UWP Api。

输出包中不需要 Windows.winmd,我建议将引用 属性 更改为 CopyLocal=false。