App.config: User vs Application Scope
.net, app-config, application-settings, c#, winforms
Solution
Basically, application settings cannot be changed during the running of a program and user settings can. These user settings should then be saved so the user is presented with a familiar experience when (s)he runs the application next.
Edit: For examples, you might write your application with different modules, and need to ensure that your main module is using the correct version of your security module. For this you would set up an application-scope setting eg:
SecurityModuleVersion string Application v1.21
Sometime later when you refactor the security module, you might change the value to v1.22 when you deploy to ensure the correct security is being implemented
On the other hand, if your application has different 'skins' with color changes, font changes etc, then you may setup a user setting something like the following:
ApplicationSkin string User DefaultSkin
Then, when Michelle changes to the skin she prefers, the application remembers her settings. The properties may now look like:
ApplicationSkin string User HelloKittySkin
Problem
I have added App.config file in my project. I have created two settings from Project > Properties > Settings panel - I have noticed that when I am adding a setting, I can define scope as `User` or `Application`. - - User - Application If I define setting as `User` it goes to`userSettings` section, if I define setting as `Application` it goes to `applicationSettings` section App.config ``` <configuration> <userSettings> <DemoApp.Properties.Settings> <setting name="MySetting1" serializeAs="String"> <value>Value1</value> </setting> </DemoApp.Properties.Settings> </userSettings> <applicationSettings> <DemoApp.Properties.Settings> <setting name="MySetting2" serializeAs="String"> <value>Value2</value> </setting> </DemoApp.Properties.Settings> </applicationSettings> </configuration> ``` But, these settings can be accessed in the same way from `.cs` - Code ``` string mySetting1 = DemoApp.Properties.Settings.Default.MySetting1; string mySetting2 = DemoApp.Properties.Settings.Default.MySetting2; ``` What is the difference between `User` and `Application` scope and under what circumstances one should choose between these two?