From b4cc81139aab09dacfa0f3b1c2955a23b8e72f67 Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Fri, 17 Jun 2022 12:40:37 -0400 Subject: [PATCH] Bug fix ( #276 ): x-thread error on fresh install --- Source/AppScaffolding/AppScaffolding.csproj | 2 +- Source/LibationWinForms/Program.cs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/AppScaffolding/AppScaffolding.csproj b/Source/AppScaffolding/AppScaffolding.csproj index 59a182d3..fc3ace9b 100644 --- a/Source/AppScaffolding/AppScaffolding.csproj +++ b/Source/AppScaffolding/AppScaffolding.csproj @@ -3,7 +3,7 @@ net6.0-windows - 8.0.1.1 + 8.0.2.1 diff --git a/Source/LibationWinForms/Program.cs b/Source/LibationWinForms/Program.cs index ecf2344a..2abbea83 100644 --- a/Source/LibationWinForms/Program.cs +++ b/Source/LibationWinForms/Program.cs @@ -25,6 +25,9 @@ namespace LibationWinForms //// Only use while debugging. Acts erratically in the wild //AllocConsole(); + // run as early as possible. see notes in postLoggingGlobalExceptionHandling + Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); + ApplicationConfiguration.Initialize(); //***********************************************// @@ -193,8 +196,9 @@ namespace LibationWinForms // these 2 lines makes it graceful. sync (eg in main form's ctor) and thread exceptions will still crash us, but event (sync, void async, Task async) will not Application.ThreadException += (_, e) => MessageBoxLib.ShowAdminAlert(null, "Libation has encountered an unexpected error.", "Unexpected error", e.Exception); - // I never found a case where including made a difference. I think this enum is default and including it will override app user config file - Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); + // move to beginning of execution. crashes app if this is called post-RunInstaller: System.InvalidOperationException: 'Thread exception mode cannot be changed once any Controls are created on the thread.' + //// I never found a case where including made a difference. I think this enum is default and including it will override app user config file + //Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); } } }