Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在客户端计算机上调试WPF_Wpf - Fatal编程技术网

在客户端计算机上调试WPF

在客户端计算机上调试WPF,wpf,Wpf,捕获wpf应用程序中错误的最佳方法是什么。我已将以下内容添加到我的app.xaml.cs中: void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { var stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("{0}\n", e.Exception.Message);

捕获wpf应用程序中错误的最佳方法是什么。我已将以下内容添加到我的app.xaml.cs中:

void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{

    var stringBuilder = new StringBuilder();
    stringBuilder.AppendFormat("{0}\n", e.Exception.Message);
    stringBuilder.AppendFormat(
            "Exception handled on main UI thread {0}.", e.Dispatcher.Thread.ManagedThreadId);

    // attempt to save data
    var result = MessageBox.Show(
                    "Application must exit:\n\n" + stringBuilder.ToString() + "\n\nSave before exit?",
                    "app",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Error);
    if (result == MessageBoxResult.Yes)
    {
        MessageBox.Show(e.Exception.InnerException.ToString());
        MessageBox.Show(e.Exception.InnerException.Message.ToString());

    }

    // Return exit code
    this.Shutdown(-1);

    // Prevent default unhandled exception processing
    e.Handled = true;
}
private void Application_Startup(object sender, StartupEventArgs e)
{
    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
}

void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
    Exception ex = e.ExceptionObject as Exception;
    MessageBox.Show(ex.Message, "Uncaught Thread Exception", MessageBoxButton.OK, MessageBoxImage.Error);
}

但我仍然会遇到这样的情况:应用程序崩溃,错误没有显示在消息框中。如何调试这类错误?windows的事件日志没有显示任何有用的信息。当然,该应用程序在IDE中运行良好,因此这也没有真正的帮助。

在IDE中,您可以捕获它。转到
调试->异常。

在对话框中,选中公共语言运行时异常的抛出复选框

现在,您可以从IDE捕获它


HTH

很抱歉,您的回答没有回答我的问题:当我的错误处理没有捕获异常,但应用程序只是说它停止工作时,如何在客户端计算机上而不是在IDE中调试应用程序