Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add User Settings at runtime in a c# application

I want to add new settings to the user.config at runtime for a C# application (WPF). These settings will be added by independent modules so I have no idea what they will be in advance.

Most examples refer to:

Configuration config =
    configurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

But this only allows you to access the Application Settings and you can't save it anyway as it's not meant to be modified.

I want to be able to do something like

Settings.Default.Add("SomeKey", "someobject");
Settings.Default.Save()

after which this setting would be available the next time this specific user starts the application.

like image 631
TimothyP Avatar asked Jun 02 '26 01:06

TimothyP


1 Answers

You may wish to check this solution.

It is doable but it is lots of code.

like image 100
Jan Avatar answered Jun 03 '26 15:06

Jan