本文介绍了currentDomain.UnhandledExcepti ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用数据库应用程序。我已经处理了 currentDomain.UnhandledException 并将一个新窗口显示为对话框。

但是当出现UnhandledException时,对话框窗口会出现但已冻结。我无法处理它。

I am working in a database application. I have handled the currentDomain.UnhandledException and showing a new window as a dialog.
But when the UnhandledException occurs the dialog window appears but frozen. I cannot deal with it.

Private Sub UnhandledExceptionHandled(sender As Object, e As UnhandledExceptionEventArgs)
      Dim es As Exception = DirectCast(e.ExceptionObject, Exception)
 Writer.WriteLine(es.Message & System.Reflection.MethodBase.GetCurrentMethod().Name)
      Writer.Close()
      Dim Wnd As New ErrorWindow
      Try
          If Wnd.ShowDialog() Then
          ' Do something
          End If
      Catch ex As Exception
      End Try
  End Sub



ErrorWindow 是一个普通窗口。显示后我无法处理。


ErrorWindow is an ordinary window. after showing I cannot deal with.

推荐答案

class MyApplication: Application {

     internal MyApplication() {
         DispatcherUnhandledException += (sender, eventArgs) => {
             ShowException(eventArgs.Exception);
             eventArgs.Handled = true;
         }; //DispatcherUnhandledException
     } //MyApplication

     void ShowException(System.Exception exception) {
         // show exception information
         // if you use some MessageBox or some other window in modal mode,
         // it won't freeze :-)
     }

     // ...

}





-SA


这篇关于currentDomain.UnhandledExcepti ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:25