From 3c544822489e6b92e466d4c6accdd0f18cdd83fd Mon Sep 17 00:00:00 2001 From: Markus Stoll Date: Sun, 20 Jul 2014 11:12:22 +0200 Subject: [PATCH] Catch all unhandled Exceptions --- SparkleShare/Program.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/SparkleShare/Program.cs b/SparkleShare/Program.cs index 4b98c8a8..5de52239 100644 --- a/SparkleShare/Program.cs +++ b/SparkleShare/Program.cs @@ -68,6 +68,8 @@ namespace SparkleShare { } try { + AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; + Controller = new SparkleController (); Controller.Initialize (); @@ -85,5 +87,18 @@ namespace SparkleShare { GC.WaitForPendingFinalizers (); #endif } + + static void OnUnhandledException(object sender, UnhandledExceptionEventArgs exceptionArgs) + { + try + { + var e = (Exception)exceptionArgs.ExceptionObject; + SparkleLogger.WriteCrashReport(e); + } + finally + { + Environment.Exit (-1); + } + } } }