rosenk
Programmer
- Jan 16, 2003
- 403
I'm trying to add a more reasonable error dialog to my application than the default for an unhandled exception. I've more or less figured out how to do this with the following code excerpts:
[tt]
Dim currentdomain As AppDomain = AppDomain.CurrentDomain
AddHandler currentdomain.UnhandledException, AddressOf CrashHandler
...
Public Shared Sub CrashHandler(ByVal sender As Object, ByVal args As UnhandledExceptionEventArgs)
Dim e As Exception = DirectCast(args.ExceptionObject, Exception)
Dim dlg As New CrashDataViewer
dlg.Exception = e
dlg.ShowDialog()
End Sub[/tt]
The [tt]CrashDataViewer[/tt] is my own dialog box that displays some information from the unhandled exception, including the stack trace and the like, giving the users the ability to copy text into the clipboard that they can paste into an email, providing crash data to the developer without the user having to understand what it means at all.
The problem is that when the user closes my dialog box, the application immediately terminates. If I leave the default exception handler, the user has the option to "Continue" and the application continues along in most cases.
How can I provide that ability in my own unhandled exception handler?
[tt]
Dim currentdomain As AppDomain = AppDomain.CurrentDomain
AddHandler currentdomain.UnhandledException, AddressOf CrashHandler
...
Public Shared Sub CrashHandler(ByVal sender As Object, ByVal args As UnhandledExceptionEventArgs)
Dim e As Exception = DirectCast(args.ExceptionObject, Exception)
Dim dlg As New CrashDataViewer
dlg.Exception = e
dlg.ShowDialog()
End Sub[/tt]
The [tt]CrashDataViewer[/tt] is my own dialog box that displays some information from the unhandled exception, including the stack trace and the like, giving the users the ability to copy text into the clipboard that they can paste into an email, providing crash data to the developer without the user having to understand what it means at all.
The problem is that when the user closes my dialog box, the application immediately terminates. If I leave the default exception handler, the user has the option to "Continue" and the application continues along in most cases.
How can I provide that ability in my own unhandled exception handler?