private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) { Exception exception = e.ExceptionObject as Exception ?? new Exception(); File.WriteAllText("crash_" + DateTime.UtcNow.ToString("yyyy-MM-dd_HH-mm-ss") + ".txt", exception.ToString()); ErrorReport_frm error = new ErrorReport_frm(exception); error.ShowDialog(); Console.WriteLine(exception.ToString()); Process.GetCurrentProcess().Kill(); }