3

Alright I'm trying to learn all the different options on how to implement application and user settings and it is all very confusing to me.

What is the difference between using the settings.settings designer that creates a <applicationSettings> section and using the ConfigurationManager.AppSettings property that, according to the documentation, creates a <appSettings> section?

What are the advantages/disadvantages of using the settings.settings designer for app/user settings?

Am I correct if I assume the classes in the System.Configuration namespace (particularly the System.Configuration.Configuration class) are primarily for creating custom sections?

Can anything in the System.Configuration namespace be used to create or read the <applicationSettings> section without using the settings.settings designer? Would that just be a custom section?

As you can see I am very confused... I hope my questions even make since. Please, just tell me what you know and I'll continue to plow through this documentation trying to UNDERSTAND. My problem isn't that I can't get the job done that I need to get done (I can do what I need using the settings.settings).... The problem is actually understanding this mess and knowing all my options.

Thank you in advance.

UPDATE:

Microsoft online documentation is horrible on this topic (non-existant basically). I finally found

http://www.codeproject.com/Articles/19675/Cracking-the-Mysteries-of-NET-2-0-Configuration

and this explained it all very well. It made much more since after i realized the config files are merged!

1

2 Answers 2

3

Both the settings.settings and .config (app.config, web.config, or whatever) essentially do the same thing - that is, they store values in an XML file that can be persisted across sessions (the settings.settings also creates a public property in the Settings.Designer.* file, so the VS designer can read from it).

The *.config file is the older way of doing things, and the settings.setttings is the "newer" way to do things. With settings.settings, you also have a handy interface for adding objects (i.e., directly from Visual Studio, instead of editing the XML by hand).

Also, with settings.settings, you get User scope, and Application scope. User scope is read/write during run-time, while I believe the Application scope is read-only during run-time.

The System.Configuration namespace is for both reading and writing to the *config file.

A good option for dealing with the *.config files is to use Rick Strahl's configuration manager tool. It creates a nice object oriented-view of the entire *.config file, allows for eacy encryption of entries, etc.

1

The Settings.Settings stuff you are seeing is what you want to use for user-specific settings. The designer is used to set the default values of those settings. Those defaults are stored in the app.config file, which is where application settings/configuration are kept. That is: the user setting defaults are themselves application settings.

Did that help? ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.