I have a program with some DLL-extensions, that are loaded at runtime. The frontend is a CefSharp in a WinForms. But the program is already that big, uses some other 3rd party code parts (where I'm not able to take care of) and this program has to run without permanent maintenance at a far away costumer shop, that i need a global exception handler for uncaught exceptions, to handle these exceptions and log them, for analysis.
I already really searched for solutions and tutorials but there was nothing that worked for me.
The mainform just starts another assembly (and give him the form object) and this assembly "does it's thing". e.g. add the CefSharp-Browser to the form.
I tried to add a method to handle Handles Me.UnhandledException, MyBase.UnhandledException, MyClass.UnhandledException
in the ApplicationEvents.vb
Namespace My
Partial Friend Class MyApplication
Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
Me.MinimumSplashScreenDisplayTime = 0
AddHandler My.Application.UnhandledException, AddressOf UnhandledExceptionHandler
Return MyBase.OnInitialize(commandLineArgs)
End Function
Public Sub UnhandledExceptionHandler(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException, MyBase.UnhandledException, MyClass.UnhandledException
Dim errstr = $"Message: {vbNewLine}
{e.Exception.Message}{vbNewLine}
{vbNewLine}
InnerMessage: {vbNewLine}
{e.Exception.InnerException.Message}{vbNewLine}
{vbNewLine}
Stacktrace: {vbNewLine}
{e.Exception.StackTrace.ToString()}{vbNewLine}"
MsgBox($"Aa uncaught exception was thrwon! {vbNewLine} {vbNewLine} {errstr}")
End Sub
End Class
End Namespace
But this method UnhandledExceptionHandler
is never called, even exceptions where thrown that are tagged as uncaught in the debugger and causes the debugging to pauses.
So if my question was not clear: Can anybody help me or can explain to me, where i made a mistake, where could I possibly made a wrong assumption or how such a uncaught exception handler would work.
in vb.net at Visual Studio 2017