我正在使用(成功地) Parse进行推送通知,但是我想处理的情况是,当订阅Parse服务器是不成功的(通常由于糟糕的互联网连接)。
但是,它似乎是在Parse中抛出的异常,没有处理,它最终出现在默认方法private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)中,这不是我想要的。
这是密码
try
{
this.Startup += async (sender, args) =>
{
try
{
// This optional line tracks statistics around app opens, including push effectiveness:
ParseAnalytics.TrackAppOpens(RootFrame);
// By convention, the empty string is considered a "Broadcast" channel
// Note that we had to add "async" to the definition to use the await keyword
await ParsePush.SubscribeAsync("");
}
catch (Exception ex)
{
Debug.WriteLine("jupiii");
}
};
}
catch (Exception ex)
{
Debug.WriteLine("jupiii");
}我知道外部的尝试-捕获是没有意义的,但我只是尝试无论如何,它没有处理那里。
如果没有internet连接,应用程序就会异常崩溃。
[Parse.ParseException] = {Parse.ParseException: Invalid response from server ---> System.ArgumentException: Input JSON was invalid.
at Parse.Internal.Json.Parse(String input)
at Parse.ParseClient.DeserializeJsonString(String jsonData)
at Parse.ParseClient.<>c__DisplayCl...我认为问题可能在异步方法中,但我正在等待它,这应该是正确的事情,如果我想要捕获异常。
全堆栈跟踪
Parse.ParseException: Invalid response from server ---> System.ArgumentException: Input JSON was invalid.
at Parse.Internal.Json.Parse(String input)
at Parse.ParseClient.DeserializeJsonString(String jsonData)
at Parse.ParseClient.<>c__DisplayClassb.<RequestAsync>b__a(Task`1 t)
--- End of inner exception stack trace ---
at Parse.ParseClient.<>c__DisplayClassb.<RequestAsync>b__a(Task`1 t)
at Parse.Internal.InternalExtensions.<>c__DisplayClass1`2.<OnSuccess>b__0(Task t)
at Parse.Internal.InternalExtensions.<>c__DisplayClass7`1.<OnSuccess>b__6(Task t)
at System.Threading.Tasks.ContinuationResultTaskFromTask`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Parse.ParseAnalytics.<>c__DisplayClass3.<<TrackAppOpens>b__2>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__3(Object state)发布于 2015-06-03 14:40:09
我现在做了一件可怕的事情,只是为了让它发挥作用,如果你有更好的解决方案,我期待着它的到来。
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (e.ExceptionObject.Message.Contains("Invalid response from server"))
{
e.Handled = true;
return;
}
if (Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
Debugger.Break();
}
}https://stackoverflow.com/questions/30621698
复制相似问题