I have just added a setting into my application settings for my C# app. I can access the setting just fine in my code using Settings.Default.MySetting, and it's in the app.config file in my project. But no matter what I do, it never shows up in the user.config file for my application. What could I possibly be missing?
Asked
Active
Viewed 291 times
0
-
User-scoped config file is stored in User folder, see http://stackoverflow.com/questions/884260/how-can-i-watch-the-user-config-file-and-reload-the-settings-when-it-changes – Tomas Voracek Dec 27 '11 at 22:16
-
Right, and I can delete it, run my app and the file will show up again, but the setting I've just added isn't in there. Why? – Jonathan Beerhalter Dec 27 '11 at 22:17
-
What's reload? Not sure what you're talking about. – Jonathan Beerhalter Dec 27 '11 at 22:28
1 Answers
0
In the settings designer you of course need to set the scope to User
.
The <userSettings>
section in app.config is the place where defaults are stored.
Assuming your application provides a way for the user to change their settings, the settings system will write the overridden values to the user.config the first time you call the configuration.Save()
method.
also note that "user" in user.config is replaced by the user name of the identity under which the configuration was saved.

Ethan Cabiac
- 4,943
- 20
- 36
-
So the only way I can get it to work is to write a value to my config value, then call Settings.Default.Save(). Then the entry shows up in the user.config. Something is wrong, why to I have to make fake changes to config settings before they show up in user.config? Or maybe my problem is more fundamental, and I shouldn't be using user.config like an application config file? – Jonathan Beerhalter Dec 27 '11 at 22:40
-
I recommend you make a *real* change to the setting and save it. Until then, the default value will suffice. If you can't come up with a scenario for a real change then it probably shouldn't be a setting. – Hans Passant Dec 27 '11 at 22:56
-
@JonathanBeerhalter Why do you need something other than the default value unless it has changged? – Ethan Cabiac Dec 28 '11 at 15:25