From bc46ccadb39d52a0650c7584e1874c65a01df3bd Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 14 Oct 2020 14:37:52 +0200 Subject: [PATCH] Add UnhandledException EventHandler --- app/DD_PM_WINDREAM/ApplicationEvents.vb | 24 ++++++++++++++++++++++++ app/DD_PM_WINDREAM/DD_PM_WINDREAM.vbproj | 1 + 2 files changed, 25 insertions(+) create mode 100644 app/DD_PM_WINDREAM/ApplicationEvents.vb diff --git a/app/DD_PM_WINDREAM/ApplicationEvents.vb b/app/DD_PM_WINDREAM/ApplicationEvents.vb new file mode 100644 index 0000000..1314cba --- /dev/null +++ b/app/DD_PM_WINDREAM/ApplicationEvents.vb @@ -0,0 +1,24 @@ +Imports Microsoft.VisualBasic.ApplicationServices + +Namespace My + ' Für MyApplication sind folgende Ereignisse verfügbar: + ' Startup: Wird beim Starten der Anwendung noch vor dem Erstellen des Startformulars ausgelöst. + ' Shutdown: Wird nach dem Schließen aller Anwendungsformulare ausgelöst. Dieses Ereignis wird nicht ausgelöst, wenn die Anwendung mit einem Fehler beendet wird. + ' UnhandledException: Wird bei einem Ausnahmefehler ausgelöst. + ' StartupNextInstance: Wird beim Starten einer Einzelinstanzanwendung ausgelöst, wenn die Anwendung bereits aktiv ist. + ' NetworkAvailabilityChanged: Wird beim Herstellen oder Trennen der Netzwerkverbindung ausgelöst. + Partial Friend Class MyApplication + Private Sub MyApplication_UnhandledException(sender As Object, e As UnhandledExceptionEventArgs) Handles Me.UnhandledException + Dim oMessage = "Application encountered an unhandled error!" & vbNewLine & vbNewLine & + "The errormessage was:" & vbNewLine & e.Exception.Message & vbNewLine & + "The stacktrace was:" & vbNewLine & e.Exception.StackTrace + + If IsNothing(LOGGER) = False Then + LOGGER.Info(oMessage) + LOGGER.Error(e.Exception) + End If + + MsgBox(oMessage, MsgBoxStyle.Critical, "Process Manager") + End Sub + End Class +End Namespace diff --git a/app/DD_PM_WINDREAM/DD_PM_WINDREAM.vbproj b/app/DD_PM_WINDREAM/DD_PM_WINDREAM.vbproj index 5458cfc..ff4c9fd 100644 --- a/app/DD_PM_WINDREAM/DD_PM_WINDREAM.vbproj +++ b/app/DD_PM_WINDREAM/DD_PM_WINDREAM.vbproj @@ -237,6 +237,7 @@ +