Hello, I have this project that is experiencing some problems with what should be my code for the problem handler.
Public Event UnhandledException As UnhandledExceptionEventHandler Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim currentDomain As AppDomain = AppDomain.CurrentDomain AddHandler currentDomain.UnhandledException, AddressOf MyHandler End Sub Sub MyHandler(ByVal sender As Object, ByVal args As UnhandledExceptionEventArgs) Dim e As Exception = DirectCast(args.ExceptionObject, Exception) Using sw As New StreamWriter(File.Open(myFilePath, FileMode.Append)) sw.WriteLine(Date.now & e.toString) End Using MessageBox.Show("An unexcpected error occured. Application will be terminated.") Application.Exit() End Sub Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click Throw New Exception("Dummy Error") End Sub
I am trying to globally catch all exceptions and create a log file at runtime that works fine in the debugger (exception handling and writing to a text file), but cannot catch any unhandled exceptions after I create it in the installation project and install into the car, what am I missing? Do I need to include additional components in my installation project? Help will be greatly appreciated
source share