views:

76

answers:

2

When creating my application's or library's configuration, I generally prefer using a custom configuration section over the <appSettings> section for the following reasons.

  • Framework serialization to a user-defined configuration object; each config value has an appropriate type
  • Configuration values may be validated against type and value ranges with attributes

Given this, when would I want to use the loose-typed <add/> key/value mechanism of the <appSettings> section? As I recall, application-level configuration in this section can override existing machine-level configuration from machine.config. Is this the only case, or are there other reasons?

+1  A: 

The appSettings tag has a "file" attribute that allows you to redirect your entire appSettings section to an external file. So for example you can have different appSettings instances for different environments: dev.config, qa.config, etc. I'm not sure if you can do that with other configuration sections though.

Example:

<appSettings file="qa.config"/>
dacris
You can do this with ApplicationSettings and configSource too.
Dirk
+3  A: 

It's easier for quick-and-dirty applications.

It's the same reason ASP.NET has things like the magic "Page_Load" method - no explicit wiring, you probably don't use it in an enterprise-y application; it's just there for RAD.

Rex M