VB Application - Unhandle Exception not working in Release mode

70 Views Asked by At

VB winforms Application, I have added this code in the ApplicationEvents so that I can catch all the unhandled exceptions and log them.

Private Sub Application_Startup(sender As Object, e As Application.StartupEventArgs) Handles Me.Startup
     AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf Application_UnhandledException
End Sub

Private Sub Application_UnhandledException(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)     
    'My code for log
End Sub

This works perfectly in debug mode, but when it comes to Release this function is never called and I didn't understand why

I tried to see if their is a problem in the application config file

0

There are 0 best solutions below