From 6842fe54342c07a4610d01ad34ca7b7e00b0e524 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Mon, 6 Nov 2023 22:44:13 -0500 Subject: [PATCH] Catch ManagementExceptions when starting WindowsThemeService --- TwitchDownloaderWPF/Services/WindowsThemeService.cs | 8 +++++++- TwitchDownloaderWPF/Translations/Strings.Designer.cs | 3 +-- TwitchDownloaderWPF/Translations/Strings.fr.resx | 2 +- TwitchDownloaderWPF/Translations/Strings.resx | 2 +- TwitchDownloaderWPF/TwitchDownloaderWPF.csproj | 10 +++++----- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/TwitchDownloaderWPF/Services/WindowsThemeService.cs b/TwitchDownloaderWPF/Services/WindowsThemeService.cs index aebcbd54..97557291 100644 --- a/TwitchDownloaderWPF/Services/WindowsThemeService.cs +++ b/TwitchDownloaderWPF/Services/WindowsThemeService.cs @@ -41,7 +41,13 @@ public WindowsThemeService() } catch (ExternalException e) { - MessageBox.Show(string.Format(Translations.Strings.UnableToStartWindowsThemeWatcher, $"0x{e.ErrorCode:x8}"), Translations.Strings.MessageBoxTitleError, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(string.Format(Translations.Strings.UnableToStartWindowsThemeWatcher, $"0x{e.ErrorCode:x8}"), Translations.Strings.MessageBoxTitleError, + MessageBoxButton.OK, MessageBoxImage.Information); + } + catch (ManagementException e) + { + MessageBox.Show(string.Format(Translations.Strings.UnableToStartWindowsThemeWatcher, $"{e.ErrorCode} (0x{(int)e.ErrorCode:x8})"), Translations.Strings.MessageBoxTitleError, + MessageBoxButton.OK, MessageBoxImage.Information); } } diff --git a/TwitchDownloaderWPF/Translations/Strings.Designer.cs b/TwitchDownloaderWPF/Translations/Strings.Designer.cs index 2680bae6..e41a9ea0 100644 --- a/TwitchDownloaderWPF/Translations/Strings.Designer.cs +++ b/TwitchDownloaderWPF/Translations/Strings.Designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -1861,7 +1860,7 @@ public static string UnableToParseLinkMessage { } /// - /// Looks up a localized string similar to Unable to start Windows application theme watcher. Error code: {0}. + /// Looks up a localized string similar to Unable to start Windows application theme watcher. Real-time Windows theme synchronization has been disabled. Error code: {0}. /// public static string UnableToStartWindowsThemeWatcher { get { diff --git a/TwitchDownloaderWPF/Translations/Strings.fr.resx b/TwitchDownloaderWPF/Translations/Strings.fr.resx index 6be5233c..a416e24e 100644 --- a/TwitchDownloaderWPF/Translations/Strings.fr.resx +++ b/TwitchDownloaderWPF/Translations/Strings.fr.resx @@ -769,7 +769,7 @@ Erreur - Impossible de démarrer l'observateur de thème de l'application Windows. Code d'erreur : {0} + Impossible de démarrer l'observateur de thème de l'application Windows. La synchronisation des thèmes Windows en temps réel a été désactivée. Code d'erreur : {0} Vidéos par page: diff --git a/TwitchDownloaderWPF/Translations/Strings.resx b/TwitchDownloaderWPF/Translations/Strings.resx index 1f22a7b8..709896f7 100644 --- a/TwitchDownloaderWPF/Translations/Strings.resx +++ b/TwitchDownloaderWPF/Translations/Strings.resx @@ -768,7 +768,7 @@ Error - Unable to start Windows application theme watcher. Error code: {0} + Unable to start Windows application theme watcher. Real-time Windows theme synchronization has been disabled. Error code: {0} Videos per page: diff --git a/TwitchDownloaderWPF/TwitchDownloaderWPF.csproj b/TwitchDownloaderWPF/TwitchDownloaderWPF.csproj index 0b8fd66b..92784ef4 100644 --- a/TwitchDownloaderWPF/TwitchDownloaderWPF.csproj +++ b/TwitchDownloaderWPF/TwitchDownloaderWPF.csproj @@ -42,14 +42,14 @@ - $(DefaultXamlRuntime) - Designer - Never + Always - Never + Always + + + Always -