From 3def2f40c033885cd71f2d7498f882d73973d505 Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Mon, 7 Feb 2022 20:22:38 +0100 Subject: [PATCH] [BUG] "Store config at the assembly location" not working for "protected folder locations" (#321), version 1.2.6.2 --- Properties/AssemblyInfo.cs | 4 ++-- Properties/CustomSettingsProvider.cs | 8 ++++---- UserInterface/AppContextMenu.cs | 2 +- UserInterface/SettingsForm.cs | 16 ++++++++++++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index c28efd7..37fa2da 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -39,5 +39,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.6.1")] -[assembly: AssemblyFileVersion("1.2.6.1")] +[assembly: AssemblyVersion("1.2.6.2")] +[assembly: AssemblyFileVersion("1.2.6.2")] diff --git a/Properties/CustomSettingsProvider.cs b/Properties/CustomSettingsProvider.cs index dae2847..9aa21ce 100644 --- a/Properties/CustomSettingsProvider.cs +++ b/Properties/CustomSettingsProvider.cs @@ -43,6 +43,10 @@ namespace SystemTrayMenu.Properties $"SystemTrayMenu"), $"user-{Environment.MachineName}.config"); + public static string ConfigPathAssembly => Path.Combine( + Directory.GetParent(Assembly.GetEntryAssembly().Location).FullName, + $"user.config"); + /// /// Gets or sets override. /// @@ -56,10 +60,6 @@ namespace SystemTrayMenu.Properties } } - private static string ConfigPathAssembly => Path.Combine( - Directory.GetParent(Assembly.GetEntryAssembly().Location).FullName, - $"user.config"); - /// /// Gets or sets in memory storage of the settings values. /// diff --git a/UserInterface/AppContextMenu.cs b/UserInterface/AppContextMenu.cs index 0ca59c6..1cd150e 100644 --- a/UserInterface/AppContextMenu.cs +++ b/UserInterface/AppContextMenu.cs @@ -114,7 +114,7 @@ namespace SystemTrayMenu.Helper aboutBox.AppMoreInfo += "#235 #242 243 #247, #271 Tom, #237 Torsten S., #240 video Patrick, #244 Gunter D., #246 MACE4GITHUB, #259 #310 vanjac, "; aboutBox.AppMoreInfo += "#262 terencemcdonnell, #269 petersnows25, #272 Peter M., #273 #274 ParasiteDelta, #275 #276 #278 donaldaken, "; aboutBox.AppMoreInfo += "#277 Jan S., #282 akuznets, #283 #284 #289 RuSieg, #285 #286 dao-net, #288 William P., #294 #295 #296 Stefan Mahrer, "; - aboutBox.AppMoreInfo += "#225 #297 #299 #317 chip33, #298 phanirithvij, #306 wini2" + Environment.NewLine; + aboutBox.AppMoreInfo += "#225 #297 #299 #317 #321 chip33, #298 phanirithvij, #306 wini2" + Environment.NewLine; aboutBox.AppMoreInfo += @" Sponsors - Thank you! ------------------ diff --git a/UserInterface/SettingsForm.cs b/UserInterface/SettingsForm.cs index 4d6aa63..6ab3894 100644 --- a/UserInterface/SettingsForm.cs +++ b/UserInterface/SettingsForm.cs @@ -865,14 +865,26 @@ namespace SystemTrayMenu.UserInterface if (checkBoxStoreConfigAtAssemblyLocation.Checked) { CustomSettingsProvider.ActivateConfigPathAssembly(); - Settings.Default.Save(); + TrySettingsDefaultSave(); } else { - Settings.Default.Save(); + TrySettingsDefaultSave(); CustomSettingsProvider.DeactivateConfigPathAssembly(); } + static void TrySettingsDefaultSave() + { + try + { + Settings.Default.Save(); + } + catch (Exception ex) + { + Log.Warn($"Failed to store config at assembly location {CustomSettingsProvider.ConfigPathAssembly}", ex); + } + } + DialogResult = DialogResult.OK; AppRestart.ByConfigChange(); Close();