views:

394

answers:

3

I know how to create custom configuration handlers for my .NET application. There are plenty of posts on StackOverflow that cover what needs to be done. I've spent most of the day knocking out classes that derive from ConfigurationElement.

I'm getting worried that this approach involves a lot of work - more work than I was expecting. I'm creating a lot of classes and decorating them with lots of attributes and I can't help thinking that a lot of this work could be embedded within a framework.

Windows Forms recently gained a feature called Application Settings. This gives you an editor for settings and it creates some code that details with serializing types into and out of config files. Application Settings appears to take a lot of the pain out of dealing with custom config, but I don't particularly like the format of the config sections that this produces and I'm not looking to save my config back.

So, my quesions are:

  1. Is it appropriate to use the Application Settings mechanism within an ASP.NET site? Will I discover perf/threading issues with this mechanism within such an app?
  2. Are there other (better) frameworks that take the hard work out of reading custom config from web.config?
A: 

I don't particularly like the Application Settings feature. I don't really like anything that auto-generates code for me, for that matter. There are instances were it's useful, but I hate the feeling of not being in control of my own project.

As for a "better" system than System.Configuration, I just can't think of any. Yeah, you'll probably end up with lots of classes and lots of attributes, but you'll also get a highly-customizable type-safe configuration mechanism that's easy for your users to use. Because, in the end, the user experience is what matters.

David Brown
A: 

Appropriate? sure. Lot of work? Definetly.

I think it's more appropriate if you are shipping your product for others to use. But if it's internal ... it may be more work/headache than it's worth.

This may be an unpopular opinion but I don't like anything Application-Specific in my config file other than 2 things.

  1. Config Provider
  2. Connection Strings

I put all my configuration settings in the database and a setting is defined in the web.config it will override the database config setting.

This has worked well for me and I have generally avoided using custom config sections as much as possible.

Chad Grant
+2  A: 

See the Configuration Section Designer.

John Saunders
This looks very promising. I'll take a look.
Martin Peck