Tips and tricks for .NET using ASP and VB code.

Restart Program After Error

Namespace My
Partial Friend Class MyApplication
Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
e.ExitApplication = False
Diagnostics.Debug.WriteLine("Unhandled Exception: " & e.Exception.Message.ToString)
If Not IsNothing(e.Exception.InnerException) Then
Diagnostics.Debug.WriteLine("Unhandled Inner Exception: " & e.Exception.InnerException.Message.ToString)
End If
Diagnostics.Debug.WriteLine("Restarting program...")
Beep()
System.Windows.Forms.Application.Restart()
End Sub
End Class
End Namespace

No comments:

Post a Comment

Search This Blog