【发布时间】:2016-03-13 12:01:39
【问题描述】:
我正在将应用内购买 IAP 添加到我的 UWP 应用中,但在测试该过程时,应用会崩溃,但只有在通过调用时显示的测试对话框批准购买后:
await CurrentAppSimulator.RequestProductPurchaseAsync(
IAPs.CoreFeatures, false);
这是我的 ViewModel 中包含的完整功能:
private async void UnlockFeaturesNow()
{
LicenseInformation licenseInformation = App.LicenseInformation;
if (!licenseInformation.ProductLicense[IAPs.CoreFeatures].IsActive)
{
try
{
// The customer doesn't own this feature, so show the purchase dialog.
await CurrentAppSimulator.RequestProductPurchaseAsyn(
IAPs.CoreFeatures, false);
//Check the license state to determine if the in-app purchase was successful.
if (!licenseInformation.ProductLicenses[IAPs.CoreFeatures].IsActive)
{
await this._messageBoxService.Show("features were not purchased.",
"Features");
}
else
{
await this._messageBoxService.Show("features were purchased
successfully.", "Features");
//Remove the purchase button from splitview popup menu.
SectionModel unlockFeatureSection = this.Sections.FirstOrDefault
(m => m.PageName == PageNameEnum.UnlockFeaturesPage);
if (unlockFeatureSection != null)
{
this.Sections.Remove(unlockFeatureSection);
unlockFeatureSection = null;
}
}
}
catch (Exception ex)
{
// The in-app purchase was not completed because an error occurred.
await this._messageBoxService.Show("Failed to purchase the features for
the following reason: " + ex.Message, "Features");
}
}
else
{
// The customer already owns this feature.
}
}
如果我取消“IAP 测试对话框”或选择“确定”以外的任何其他选项,我的应用永远不会崩溃。
如果我选择“确定”,它会告诉我我的 IAP 已成功购买,并且取决于我在应用程序中的位置,它会按预期工作,但是当我第二次点击我的汉堡菜单时,它会显示我的 SplitView 菜单,如果我点击我的应用程序上的其他任何地方它只是崩溃并显示以下错误:
"A debugger is attached to myApp.exe but not configured to debug
this unhandled exception. To debug this exception, detach the current
debugger."
我检查了我的事件查看器以获取更多信息,这就是我发现的:
Faulting application name: MyApp.exe, version: 1.0.0.0, time stamp: 0x563304b4
Faulting module name: combase.dll, version: 10.0.10586.103, time stamp: 0x56a84cbb
Exception code: 0xc000027b
Fault offset: 0x00166d7e
Faulting process ID: 0x2138
Faulting application start time: 0x01d17a76e526db18
Faulting application path: C:\MyFolder\MyApp\bin\x86\Debug\AppX\MyApp.exe
Faulting module path: C:\WINDOWS\SYSTEM32\combase.dll
Report ID: bb041374-507f-4927-84b8-75bf7cb6df63
Faulting package full name: MyApp1.1.25.0_x86__z2199h13vtehs
Faulting package-relative application ID: App
所以看起来 Combase.dll 正在崩溃,但我不知道这个 .dll 是做什么用的,为什么它只有在选择“确定”而不是其他选项后才会崩溃。
我刚刚尝试了 Microsoft 提供的 UWP Store 示例,它使用 SplitView 并提供了我正在使用的相同 IAP(场景 2)选项,当我在购买时选择 OK “IAP 测试”对话框,一切都按预期工作,所以它会让你认为这与我的代码有关,但我很确定这不是因为应用程序在使用时永远不会崩溃,并且在 IAP 测试对话框时永远不会崩溃除非我选择“确定”选项,否则显示。
明天我将继续调查,因为我的应用程序和 Microsoft 示例之间的一大区别是我使用的是 MVVM,并且此代码在我的 ViewModel 中,而不是在 XAML 页面的 Code-Behind 中。
能否告诉我您是否遇到过此问题以及是否已设法解决?
谢谢。
【问题讨论】:
-
您是否向商店提交了 IAP?如果您的应用程序因应用程序的发布版本而崩溃,您可以尝试使用 CurrentApp 而不是 CurrentAppSimulator。我更喜欢用这种方式测试简单的 IAP 场景
-
@MichalKania 我试试看。
标签: in-app-purchase win-universal-app windows-10-universal