我无法获得正确的 StoreContext

I'm unable to get a proper StoreContext

我已将我的应用程序提交到 Windows 商店并通过了认证。根据测试说明:

https://docs.microsoft.com/en-us/windows/uwp/monetize/in-app-purchases-and-trials#in-app-purchases-and-trials-using-the-windowsservicesstore-namespace

我已将该应用发布为隐藏应用。我还将应用关联到应用商店:

当我调试我的应用程序时,我从未获得正确的 StoreContext 实例。我有以下错误:

根据上面的文档link,这是我遇到的问题:

If you do not associate your project with an app in the Store, the StoreContext methods set the ExtendedError property of their return values to the error code value 0x803F6107. This value indicates that the Store doesn't have any knowledge about the app.

如何让我的应用程序(或 Visual Studio)了解我的商店信息?

我刚刚弄明白了。这些步骤必须完全按照以下顺序完成:

  1. If your app is not yet published and available in the Store, make sure your app meets the minimum Windows App Certification Kit requirements, submit your app in Partner Center, and make sure your app passes the certification process. You can configure your app so it is not discoverable in the Store while you test it. Please note the proper configuration of package flights. Incorrectly configured package flights may be not be able to be downloaded.

  2. Next, make sure you have completed the following: Write code in your app that uses the StoreContext class and other related types in the Windows.Services.Store namespace to implement in-app purchases or trial functionality. If your app offers an add-on that customers can purchase, create an add-on submission for your app in Partner Center. If you want to exclude or limit some features in a trial version of your app, configure your app as a free trial in Partner Center.

  3. With your project open in Visual Studio, click the Project menu, point to Store, and then click Associate App with the Store. Complete the instructions in the wizard to associate the app project with the app in your Partner Center account that you want to use for testing.

  4. If you have not done so already, install the app from the Store that you specified in the previous step, run the app once, and then close this app. This ensures that a valid license for the app is installed to your development device.

  5. In Visual Studio, start running or debugging your project. Your code should retrieve app and add-on data from the Store app that you associated with your local project. If you are prompted to reinstall the app, follow the instructions and then run or debug your project.

我所做的是将第 3 步和第 4 步颠倒过来,结果成功了!