I have an app that currently crashes sometimes when attempting to do an in-app-purchase on Windows Phone 10. It seems to crash without throwing an exception. I am thinking maybe another thread is crashing the app? However it does not appear that the App's UnhandledException event is dispatching.
- This crashes about 5 seconds into running
RequestProductPurchaseAsync(sku). - It does not crash if the debugger is attached. (This confuses me.)
- The log before
RequestProductPurchaseAsync(sku)is displayed and written to disk. - I never see the log in
OnUnhandledException.
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
{
try {
if (IsSimulation) {
purchaseResult = await CurrentAppSimulator.RequestProductPurchaseAsync(sku);
}
else {
Debug.Log("PurchaseProductAsync is attempting REAL PURCHASE NOW!");
// Crash ~5 seconds into this call. No exception is thrown.
purchaseResult = await CurrentApp.RequestProductPurchaseAsync(sku);
// This does not display.
Debug.Log("PurchaseProductAsync got result " + (purchaseResult == null ? "null" : purchaseResult.Status.ToString()));
}
}
catch (Exception purchaseExc) {
purchaseResult = null;
result.ErrorCode = "-285";
result.ErrorException = purchaseExc;
result.ErrorMessage = "Exceptional Error";
Debug.Log("PurchaseProductAsync got an exception when attempting to purchase from CurrentApp or CurrentAppSimulator. " + purchaseExc.GetType() + ": " + purchaseExc.Message);
}
});
Any ideas on how I can capture or debug this crash?
public App()
{
this.InitializeComponent();
appCallbacks = new AppCallbacks();
UnhandledException += OnUnhandledException;
}
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
// Never seems to run
Debug.Log("Received unhandled exception");
}