Edi Wang

.NET and Azure Developer

Exception

Windows 10 UWP开发:支持异步的全局异常处理和堆栈信息

我们写UWP应用的时候难免遇到未处理的异常,不然你的应用就会在用户面前闪退,非常没有逼格。然而Windows.UI.Xaml.Application的UnhandledException事件里面有个巨坑,就是它不能处理async异步方法里的异常。注释里也没提到这回事: // // Summary: // Occurs when an exception can be handled by app code, as forwarded from a native-level // Windows Runtime error. Apps can mark the occurrence as handled in event data. public event UnhandledExceptionEventHandler UnhandledException; 处理全局异常确实 …
Windows Async Exception UWP

Windows Phone 8 开发:应用崩溃时给作者发送错误报告邮件

我们的应用难免会爆,但是手工在各个方法上加try...catch...未必能cover到所有场景,有时候我们不希望应用吞掉错误,发生严重异常时,我们应当允许应用在用户面前爆掉。如果没有处理这些异常,应用程序的表现就是闪退。比较好的做法是在应用崩溃时给用户一个选择是否发送邮件告诉应用作者崩溃的详细日志。对于作者来说,等待DevCenter的异常报告相对而言比较被动。如果能在应用崩溃之后立即得到回馈那就可以尽早修复问题。 做法很简单,和ASP.NET网站在Global.asax中使用的全局错误处理类似,WP应用也有个全局错误处理的事件。 打开App.xaml.cs,定位到Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)事件处理函数上。 当任何未处理的异常产生时,这个函 …
Windows Phone Exception