private void MyApplication_UnhandledException(object sender, Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs e) { string myFilePath = System.Windows.Forms.Application.StartupPath + "\\ErrorLog.log"; using (StreamWriter sw = new StreamWriter(File.Open(myFilePath, FileMode.Append))) { sw.WriteLine(DateTime.Now); sw.WriteLine(C_General.GetExceptionInfo(e.Exception)); } MessageBox.Show("An unexpected error occured. Check the error log for details."); ProjectData.EndApp(); }