From 2cb212c30ec887a15269ae2d6b361143e720b234 Mon Sep 17 00:00:00 2001 From: AY Date: Mon, 17 Apr 2017 11:44:07 +0300 Subject: [PATCH] Fix FirstChanceException handling --- ContactPoint/Program.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ContactPoint/Program.cs b/ContactPoint/Program.cs index 67aa31b..a327767 100644 --- a/ContactPoint/Program.cs +++ b/ContactPoint/Program.cs @@ -379,12 +379,13 @@ static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEv static void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { -#if !DEBUG - CatchUnhandledException(sender, e.Exception, "First chance exception from '{0}'"); -#endif + if (e.Exception != null) + { + CatchUnhandledException(sender, e.Exception, "First chance exception from '{0}'", false); + } } - static void CatchUnhandledException(object sender, Exception e, string message) + static void CatchUnhandledException(object sender, Exception e, string message, bool showExceptionReporter = true) { try { @@ -403,6 +404,11 @@ static void CatchUnhandledException(object sender, Exception e, string message) Logger.LogError(e); + if (!showExceptionReporter || _disableExceptionReporter || ExceptionReporter == null || !Application.MessageLoop) + { + return; + } + #if DEBUG if (Debugger.IsAttached) { @@ -410,11 +416,6 @@ static void CatchUnhandledException(object sender, Exception e, string message) } #endif - if (_disableExceptionReporter || ExceptionReporter == null || !Application.MessageLoop) - { - return; - } - try { TakeScreenshot(ExceptionReporter);