What is the prefered way for persisting user settings for WPF applications with .net-5 , .net-6.0, .net-7.0 or .net-core>=3.0?
Where are the .NET user settings gone?
Created WPF .Net Core 3.0 Project (VS2019 V16.3.1)
Now I have seen there is no Properties.Settings section anymore.
[Update 2022: With .NET 6 it is still the same]
[Update 2023: With .NET 7 it is still the same]
After online search, started to dive into Microsoft.Extensions.Configuration.
Beside the bloated code to access the settings, now even worse -> No save?
User Configuration Settings in .NET Core
Fortunately or unfortunately the Microsoft.Extensions.Configuration does not support saving by design. Read more in this Github issue Why there is no save in ConfigurationProvider?
Read the variables at startup
var culture = new CultureInfo(Properties.Settings.Default.LanguageSettings);
when a variable changes -> immediately save it
Properties.Settings.Default.LanguageSettings = selected.TwoLetterISOLanguageName; Properties.Settings.Default.Save();
You can add the same old good settings file e.g. via the right click on the Properties -> Add -> New Item and search for the "Settings". The file can be edited in the settings designer and used as in the .net framework projects before (ConfigurationManager, Settings.Default.Upgrade(), Settings.Default.Save, etc. works).
Add also the app.config file to the project root folder (the same way via the Add -> New Item), save the settings once again, compile the project and you will find a .dll.config file in the output folder. You can change now default app values as before.
Tested with Visual Studio 1.16.3.5 and a .net core 3.0 WPF project.