diff --git a/DXMainClient/DXGUI/GameClass.cs b/DXMainClient/DXGUI/GameClass.cs index f48a1ff22..b56ca5198 100644 --- a/DXMainClient/DXGUI/GameClass.cs +++ b/DXMainClient/DXGUI/GameClass.cs @@ -148,18 +148,6 @@ protected override void Initialize() wm.ControlINIAttributeParsers.Add(new TranslationINIParser()); - MainClientConstants.DisplayErrorAction = (title, error, exit) => - { - new XNAMessageBox(wm, title, error, XNAMessageBoxButtons.OK) - { - OKClickedAction = _ => - { - if (exit) - Environment.Exit(1); - } - }.Show(); - }; - SetGraphicsMode(wm); #if WINFORMS diff --git a/DXMainClient/DXGUI/Generic/MainMenu.cs b/DXMainClient/DXGUI/Generic/MainMenu.cs index 96523ebed..19ef22e79 100644 --- a/DXMainClient/DXGUI/Generic/MainMenu.cs +++ b/DXMainClient/DXGUI/Generic/MainMenu.cs @@ -652,6 +652,19 @@ public void PostInit() CheckRequiredFiles(); CheckForbiddenFiles(); CheckIfFirstRun(); + + MainClientConstants.DisplayErrorAction = (title, error, exit) => + { + new XNAMessageBox(WindowManager, title, error, XNAMessageBoxButtons.OK) + { + OKClickedAction = _ => + { + if (exit) + Environment.Exit(1); + }, + + }.Show(); + }; } private void LoadThemeSong() diff --git a/DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs b/DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs index d6074f151..1c9a934a8 100644 --- a/DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs +++ b/DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs @@ -1395,7 +1395,7 @@ private void RefreshPlayerList(object sender, EventArgs e) lbPlayerList.Clear(); // Note: IUserCollection.GetFirst() is not guaranteed to be implemented, unless it is a SortedUserCollection - Debug.Assert(currentChatChannel.Users is SortedUserCollection); + Debug.Assert(currentChatChannel.Users is SortedUserCollection, "Channel 'users' is supposed to be a SortedUserCollection"); var current = currentChatChannel.Users.GetFirst(); while (current != null) { diff --git a/DXMainClient/Online/Channel.cs b/DXMainClient/Online/Channel.cs index e16a61dbd..9432341a6 100644 --- a/DXMainClient/Online/Channel.cs +++ b/DXMainClient/Online/Channel.cs @@ -147,8 +147,8 @@ public void OnUserListReceived(List userList) existingUser.IsAdmin = user.IsAdmin; existingUser.IsFriend = user.IsFriend; - // Note: IUserCollection.GetFirst() is not guaranteed to be implemented, unless it is a SortedUserCollection - Debug.Assert(users is SortedUserCollection); + // Note: IUserCollection.Reinsert() is not guaranteed to be implemented, unless it is a SortedUserCollection + Debug.Assert(users is SortedUserCollection, "Channel 'users' is supposed to be a SortedUserCollection"); users.Reinsert(user.IRCUser.Name); } } diff --git a/DXMainClient/PreStartup.cs b/DXMainClient/PreStartup.cs index 5a8c7a110..0d73927a1 100644 --- a/DXMainClient/PreStartup.cs +++ b/DXMainClient/PreStartup.cs @@ -234,16 +234,16 @@ public static void LogException(Exception ex, bool innerException = false) Logger.Log("Type: " + ex.GetType()); Logger.Log("Message: " + ex.Message); Logger.Log("Source: " + ex.Source); - Logger.Log("TargetSite.Name: " + ex.TargetSite.Name); + Logger.Log("TargetSite.Name: " + ex.TargetSite?.Name); Logger.Log("Stacktrace: " + ex.StackTrace); if (ex.InnerException is not null) LogException(ex.InnerException, true); } - static void HandleException(object sender, Exception ex) + public static void HandleException(object sender, Exception ex) { - LogException(ex); + LogException(ex, innerException: false); string errorLogPath = SafePath.CombineFilePath(ProgramConstants.ClientUserFilesPath, "ClientCrashLogs", FormattableString.Invariant($"ClientCrashLog{DateTime.Now.ToString("_yyyy_MM_dd_HH_mm")}.txt")); bool crashLogCopied = false;