You can set an event for unhandled exceptions in the application event file
(there is a sample VB here, but I hope you get the point)
Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException End Sub
You can find application events in the parameters of your project.
source share