C# Windows应用商店应用程序中是否存在全局异常处理程序?

C# Windows应用商店应用程序中是否存在全局异常处理程序?,c#,debugging,exception-handling,windows-8,windows-store-apps,C#,Debugging,Exception Handling,Windows 8,Windows Store Apps,对于未处理的异常,至少,我希望能够捕获详细信息并将其写入文件,以备后续可能的“调试取证”;是否有一个合适的地方/方式来完成这些任务 更新 见下面我的评论。下面是一个不适合的补充: 即使在删除xaml代码段时,我仍然会收到错误消息,甚至在清理和重建之后。。。???2单击err msg只会将我带到App.xaml的顶部,整个App.xaml现在是: <Application x:Class="SpaceOverlays.App" xmlns="http://schemas.mi

对于未处理的异常,至少,我希望能够捕获详细信息并将其写入文件,以备后续可能的“调试取证”;是否有一个合适的地方/方式来完成这些任务

更新 见下面我的评论。下面是一个不适合的补充:

即使在删除xaml代码段时,我仍然会收到错误消息,甚至在清理和重建之后。。。???2单击err msg只会将我带到App.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>

对于HTML5/JavaScript应用程序,您将该事件作为捕获信息的最后机会

对于基于XAML的应用程序,您可以使用;然而,这只捕获通过XAML(UI)框架出现的异常,并且您并不总是能够获得很多关于根本原因的信息,即使在InnerException中也是如此


针对Windows 8.1的更新:还将捕获由
异步void
方法创建的异常。在Windows8中,这样的异常只会使应用程序崩溃。LunarFrog在其网站上对此有很好的介绍。

我查看了“未处理的异常”链接。在哪里添加xaml片段?如果我把它放在App.xaml中,比如:…我得到编译时错误,“无法将内容添加到'application'类型的对象”更新添加到diesbzg之上。将代码中的异常添加到App.xaml.cs中的App()构造函数中:this.unhandledeException+=
    // 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();
    }
}