应用内购买崩溃。 [英] In-app purchasing crashes.
问题描述
Hello All,
我之前在处理免费/付费应用程序时发布了一个问题并且已经关注了该链接,但我遇到了崩溃问题。
我已经发布了应用内商品和我的应用,所以我一直在使用CurrentApp课程来完成我的工作。它一直工作正常,拉起我的应用程序内产品等。
当我在模拟器中购买产品时,它工作正常,同样适用于我的设备。当我尝试取消购买时出现问题。它会进入prouct屏幕,我可以选择安装(购买)或取消,当我点击取消并且
返回应用程序时,它会崩溃。应用程序崩溃(在模拟器和设备上)都有错误:
mscorlib中出现'System.Runtime.InteropServices.COMException'类型的第一次机会异常.ni.dll
mscorlib.ni.dll中出现"System.Runtime.InteropServices.COMException"类型的异常,并且在托管/本地边界之前未处理
类型为"System"的异常。在mscorlib.ni.dll中发生了Runtime.InteropServices.COMException,并且在托管/本地边界之前未处理
在我的桌面上以模糊的方式说出符号的崩溃。在我的笔记本电脑上,它崩溃了解其他事情。我想也许我需要有钱包功能(ID_CAP_WALLET)但问题相同。
在我尝试再次点击升级时,在购买后它也会崩溃。关于我可能做错的任何想法?我的购买功能如下:
public static readonly string InAppProductKey =" adfreeUpgrade" ;;
private async void upgrade_button_Click(object sender,RoutedEventArgs e)
{
//获取当前应用的所有应用内商品
ListingInformation products = await CurrentApp.LoadListingInformationByProductIdsAsync (new [] {InAppProductKey});
//获取ID
产品列表productListing = null;
if(!products.ProductListings.TryGetValue(InAppProductKey,out productListing))
{
MessageBox.Show(&"找不到产品信息");
返回;
}
//开始购买产品
await CurrentApp.RequestProductPurchaseAsync(productListing.ProductId,false);
ProductLicense productLicense = null;
if(CurrentApp.LicenseInformation.ProductLicenses.TryGetValue(InAppProductKey,out productLicense))
{
if(productLicense.IsActive)
{
MessageBox.Show("谢谢!你已经没有广告!重启应用程序进行更改!");
返回;
}
}
MessageBox.Show(" Product not purchase");
}
< blockquote>
所以我能够通过使用try-catch块来阻止崩溃。但是在我看过的所有例子中,这都没有实现,下面是我的代码更新,我在右边这个吗?
private async void upgrade_button_Click(对象发送者,RoutedEventArgs e)
{
ProductLicense productLicense = null;
if(CurrentApp.LicenseInformation.ProductLicenses.TryGetValue(InAppProductKey,out productLicense))
{
if(productLicense.IsActive)
{
MessageBox.Show("已经广告免费。感谢您的支持!");
返回;
}
else
{
//获取当前应用的所有应用内商品
ListingInformation products = await CurrentApp.LoadListingInformationByProductIdsAsync(new [] {InAppProductKey});
//获取ID
产品列表productListing = null;
if(!products.ProductListings.TryGetValue(InAppProductKey,out productListing))
{
MessageBox.Show(&"找不到产品信息");
返回;
}
//开始购买产品
尝试
{
await CurrentApp.RequestProductPurchaseAsync(productListing.ProductId,false);
if(CurrentApp.LicenseInformation.ProductLicenses.TryGetValue(InAppProductKey,out productLicense))
{
if(productLicense.IsActive)
{
MessageBox。显示("谢谢!你已经无广告了!重启应用程序进行更改!");
返回;
}
}
}
catch(SystemException ex)
{
MessageBox.Show(" Product not purchase");
返回;
}
}
}
}
Hello All,
I posted a question earlier on dealing with free/paid apps and have followed the link but I'm having a crash issue.
I already have the in-app product and my app published, so I've been using the CurrentApp class to do my work. It's been working fine, pulling up my in-app product and such.
When I purchase the product in the emulator it works fine, and same goes for on my device. The problem comes when I try to cancel the purchase. It'll go to the prouct screen, I have the option to install (purchase) or cancel, when I click cancel and it's returning to the app, it crashes. The app crashes (both in the emulator and on the device) with error:
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.ni.dll An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
On my desktop it crashes in a vague way speaking of symbols. On my laptop it crashes speaking of something else. I thought maybe I needed to have the Wallet capability (ID_CAP_WALLET) but same issues.
On the emulator it also crashes after a purchase when I try to click into the upgrade again. Any idea on what I may be doing wrong? My buy function is below:
public static readonly string InAppProductKey = "adfreeUpgrade"; private async void upgrade_button_Click(object sender, RoutedEventArgs e) { // get all in-app products for current app ListingInformation products = await CurrentApp.LoadListingInformationByProductIdsAsync(new[] { InAppProductKey }); // get specific in-app product by ID ProductListing productListing = null; if (!products.ProductListings.TryGetValue(InAppProductKey, out productListing)) { MessageBox.Show("Could not find product information"); return; } // start product purchase await CurrentApp.RequestProductPurchaseAsync(productListing.ProductId, false); ProductLicense productLicense = null; if (CurrentApp.LicenseInformation.ProductLicenses.TryGetValue(InAppProductKey, out productLicense)) { if (productLicense.IsActive) { MessageBox.Show("Thanks! You've gone ad-free! Restart the app to make the changes!"); return; } } MessageBox.Show("Product not purchased"); }
So I was able to stop the crashing by using a try-catch block. But in all examples I've seen, this isn't implemented, below is my code update, am I in the right on this?
private async void upgrade_button_Click(object sender, RoutedEventArgs e) { ProductLicense productLicense = null; if (CurrentApp.LicenseInformation.ProductLicenses.TryGetValue(InAppProductKey, out productLicense)) { if (productLicense.IsActive) { MessageBox.Show("Already Ad Free. Thanks for the support!"); return; } else { // get all in-app products for current app ListingInformation products = await CurrentApp.LoadListingInformationByProductIdsAsync(new[] { InAppProductKey }); // get specific in-app product by ID ProductListing productListing = null; if (!products.ProductListings.TryGetValue(InAppProductKey, out productListing)) { MessageBox.Show("Could not find product information"); return; } // start product purchase try { await CurrentApp.RequestProductPurchaseAsync(productListing.ProductId, false); if (CurrentApp.LicenseInformation.ProductLicenses.TryGetValue(InAppProductKey, out productLicense)) { if (productLicense.IsActive) { MessageBox.Show("Thanks! You've gone ad-free! Restart the app to make the changes!"); return; } } } catch (SystemException ex) { MessageBox.Show("Product not purchased"); return; } } } }
这篇关于应用内购买崩溃。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!