对于未处理的异常,我想至少能够捕获详细信息并将其写入文件以供潜在的“调试取证”。在Windows Store应用程序中没有“OnTerminating”事件;是否有适当的位置/方式来完成此操作?
更新
请参见下面我的评论。以下是不适合下面的补充内容:
即使删除了XAML片段,我仍然会收到该错误消息,并且即使在清理和重建之后...??? 双击错误消息只会将我带到App.xaml的顶部,现在它的全部内容如下:
<Application
x:Class="SpaceOverlays.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SpaceOverlays">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--
Styles that define common aspects of the platform look and feel
Required by Visual Studio project and item templates
-->
<ResourceDictionary Source="Common/StandardStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
更新 2
在关闭 App.xaml 并重新构建后,一切正常了……???哦,那好吧——结果美满就好。
更新 3
有趣的是,Windows Phone 应用程序的 App.xaml.cs 默认情况下具有此处理程序:
// Global handler for uncaught exceptions.
UnhandledException += Application_UnhandledException;
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
Debugger.Break();
}
}