Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 尝试测试应用内产品购买时出现TargetInvestment异常_C#_Windows Phone 8_In App Purchase - Fatal编程技术网

C# 尝试测试应用内产品购买时出现TargetInvestment异常

C# 尝试测试应用内产品购买时出现TargetInvestment异常,c#,windows-phone-8,in-app-purchase,C#,Windows Phone 8,In App Purchase,我正在尝试在C中测试Windows Phone 8应用程序的应用程序内产品购买# 我一直在关注如何实施这样的事情 在以下链接中: 我试图做的动作是:点击按钮 代码如下: async private void btnBuy50Points_Click_1(object sender, RoutedEventArgs e) { // 50 Points - Consumable var listing = await CurrentApp.LoadListin

我正在尝试在C中测试Windows Phone 8应用程序的应用程序内产品购买#

我一直在关注如何实施这样的事情 在以下链接中:

我试图做的动作是:点击
按钮

代码如下:

async private void btnBuy50Points_Click_1(object sender, RoutedEventArgs e)
    {
        // 50 Points - Consumable
        var listing = await CurrentApp.LoadListingInformationAsync();
        var fiftypoints =
          listing.ProductListings.FirstOrDefault(
          p => p.Value.ProductId == "coinX" && p.Value.ProductType == ProductType.Consumable);

        try
        {
            receipt = await CurrentApp.RequestProductPurchaseAsync(fiftypoints.Value.ProductId, true);

            if (CurrentApp.LicenseInformation.ProductLicenses[fiftypoints.Value.ProductId].IsActive)
            {
                CurrentApp.ReportProductFulfillment(fiftypoints.Value.ProductId);
                Coins += 50;
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }
调试时:应用程序崩溃,出现
TargetInvocationException


第行:
var listing=wait CurrentApp.LoadListingInformationAsync()

我的代码中没有编码错误,我只是在3小时后完成了相同的过程,它工作了,问题是我必须在提交应用内产品时等待2小时,然后才能测试它。

内部异常是什么?你能试着在
任务内调用。Run()
lambda吗?我模糊地记得它在UI线程上不起作用。@PeterTorr MSFT它现在起作用了,事实证明,你必须等到microsoft在提交产品时批准该应用程序,然后你才能测试它,我现在该怎么办?回答我自己的问题?是的,你可以回答你自己的问题。