Visual Studio:将 UWP Windows.ApplicationModel.Store 添加到非 UWP 项目

Visual Studio: Add UWP Windows.ApplicationModel.Store to non-UWP Project

是否可以将 Windows 商店应用内购买功能添加到非通用 Windows 平台 (UWP) .NET 项目(class 库 .dll 项目) Visual Studio 2017?

背景: 我有一个用于 Delphi 项目的 Inno Setup 安装程序,该项目使用 Microsoft 的桌面应用程序转换器(来自桌面桥项目)进行转换。我想通过将 Windows.ApplicationModel.Store 命名空间和购买逻辑添加到创建为 RemObjects Hydra 插件的 .NET 程序集来启用应用内购买功能。通过这样做,我的 Delphi 应用可以使用 Hydra 插件执行应用内购买。

如果有更好的解决方案来实现 Windows 使用已使用桌面应用程序转换器转换的经典 Windows 应用程序 (CWA) 进行商店应用程序内购买,我会洗耳恭听。

Is it possible to add Windows Store in-app purchase capability to a non-Universal Windows Platform (UWP) .NET project (class library .dll project) in Visual Studio 2017?

是的。但是,根据Windows.ApplicationModel.Storedocument

The Windows.ApplicationModel.Store namespace is not supported in Windows desktop applications that use the Desktop Bridge. These applications must use the Windows.Services.Store namespace to implement in-app purchases and trials.

另外,Windows.Services.Store命名空间也是为了更好的性能而设计的。

顺便说一下,对于 Desktop Bridge 应用程序,当您使用 StoreContext class 在您的项目中实现应用程序内购买时,您可能需要添加额外的代码。如果您的应用程序有一个与呈现框架关联的 window 句柄,您需要指定哪个应用程序 windows 是该对象显示的模态对话框的所有者 windows。

详细步骤可以参考Using the StoreContext class with Desktop Bridge.