static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { try { File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _fileName), (e.ExceptionObject as Exception).ToLogString(Environment.StackTrace)); } catch (Exception) { // ignored } var errorForm = new AppErrorForm(); errorForm.ShowDialog(); Application.Exit(); }
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { try { File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _fileName), e.Exception.ToLogString(Environment.StackTrace)); } catch (Exception) { // ignored } var f = new AppErrorForm(); f.ShowDialog(); Application.Exit(); }