【问题标题】:Windows Phone 8 IAP throws exceptionWindows Phone 8 IAP 引发异常
【发布时间】:2014-05-05 20:59:31
【问题描述】:

好的,所以我觉得我几乎可以完成这项工作。我设置了 WP8 商店应用程序(作为测试版),密钥在应用程序内是正确的。如果这是相关的,我正在使用 MonoGame 并在从更新线程启动的单独任务中进行调用。

当应用启动时,我会像这样加载许可证信息

            mProductList = await CurrentApp.LoadListingInformationAsync();

            foreach (var product in mProductList.ProductListings)
            {
                Debug.WriteLine(string.Format("{0}, {1}, {2}, {3}, {4}",
                  product.Key,
                  product.Value.Name,
                  product.Value.FormattedPrice,
                  product.Value.ProductType,
                  product.Value.Description));
            }

这部分工作正常(调试列表部分是我从教程中借来的,所以不是我写的)。这行得通,信息显示正确。

diamond_pack_small, Small diamond pack (beta), $0.00, Consumable, Small diamonds. In a pack.

但是,当我调用实际购买方法时如下图所示:

    public async Task<IAPPurchase> BuyProduct(string identifier)
    {
        if (!CurrentApp.LicenseInformation.ProductLicenses.ContainsKey(identifier))
        {
            string receipt = null;
            try
            {
                receipt = await CurrentApp.RequestProductPurchaseAsync(identifier, true);
            }
            catch (Exception e)
            {
                if (Debugger.IsAttached)
                    Debugger.Break();

                return null;
            }

我的调试器在这里中断

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

我在这里不知所措。堆栈跟踪显示了这么多:

at Windows.ApplicationModel.Store.CurrentApp.RequestProductPurchaseAsync(String productId, Boolean includeReceipt)

我检查了 product.Key 是否与传递给 BuyProduct 的标识符相对应。

【问题讨论】:

    标签: windows-phone-8 in-app-purchase


    【解决方案1】:

    好吧,因为我使用的是 Monogame,所以我从非 UI 线程发起调用,导致灾难性失败。使用 Dispatcher 来编组对 UI 线程的调用,生活再次变得美好,我可以继续。

    【讨论】:

    • 我正在序列化渲染线程上的所有触摸事件以及 IAP 调用。我刚刚意识到必须在您收到 OnPointerPressed 的同一线程上调用 IAP 调用
    • 是的,在混合 UI (XAML) 和非 UI 内容时会有很多陷阱。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-12
    • 2013-08-15
    • 1970-01-01
    相关资源
    最近更新 更多