public static void Inititialize() { Console.WriteLine("Error Logging Enabled."); AppDomain.CurrentDomain.FirstChanceException += delegate(object sender, FirstChanceExceptionEventArgs exceptionArgs) { if (LogAllExceptions && 0 == 0) { string text2 = exceptionArgs.Exception.ToString(); Console.Write("================\r\n" + $"{DateTime.Now}: First-Chance Exception\r\nThread: {Thread.CurrentThread.ManagedThreadId} [{Thread.CurrentThread.Name}]\r\nCulture: {Thread.CurrentThread.CurrentCulture.Name}\r\nException: {text2}\r\n" + "================\r\n\r\n"); } if (DumpOnException) { CrashDump.WriteException(CrashDump.Options.WithIndirectlyReferencedMemory, DumpPath); } }; AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs exceptionArgs) { string text = exceptionArgs.ExceptionObject.ToString(); Console.Write("================\r\n" + $"{DateTime.Now}: Unhandled Exception\r\nThread: {Thread.CurrentThread.ManagedThreadId} [{Thread.CurrentThread.Name}]\r\nCulture: {Thread.CurrentThread.CurrentCulture.Name}\r\nException: {text}\r\n" + "================\r\n"); if (DumpOnCrash) { CrashDump.WriteException(CrashDumpOptions, DumpPath); } }; }
public static void Inititialize() { Console.WriteLine("Error Logging Enabled."); AppDomain.CurrentDomain.FirstChanceException += (EventHandler <FirstChanceExceptionEventArgs>)((sender, exceptionArgs) => { if (!CrashWatcher.LogAllExceptions) { return; } Console.Write("================\r\n" + string.Format("{0}: First-Chance Exception\r\nThread: {1} [{2}]\r\nCulture: {3}\r\nException: {4}\r\n", (object)DateTime.Now, (object)Thread.CurrentThread.ManagedThreadId, (object)Thread.CurrentThread.Name, (object)Thread.CurrentThread.CurrentCulture.Name, (object)exceptionArgs.Exception.ToString()) + "================\r\n\r\n"); }); AppDomain.CurrentDomain.UnhandledException += (UnhandledExceptionEventHandler)((sender, exceptionArgs) => { Console.Write("================\r\n" + string.Format("{0}: Unhandled Exception\r\nThread: {1} [{2}]\r\nCulture: {3}\r\nException: {4}\r\n", (object)DateTime.Now, (object)Thread.CurrentThread.ManagedThreadId, (object)Thread.CurrentThread.Name, (object)Thread.CurrentThread.CurrentCulture.Name, (object)exceptionArgs.ExceptionObject.ToString()) + "================\r\n"); if (!CrashWatcher.DumpOnCrash) { return; } CrashDump.WriteException(CrashWatcher.CrashDumpOptions, CrashWatcher.DumpPath); }); }