I am working on a web app that will heavily rely on configuration. The configuration is also will be written by another process or human. I am looking to get response on best practices in .net 3.5 on how to implement this case. I had used the configuration section of an early version of the Enterprise Library Applications Block. I really liked working with it but from what I hear it is discontinued in current versions. Hence the question…
Need to be able to serialize collections, pick up file write event to reload new instance of config into memory.
Thank you.
Have you looked at the System.Configuration namespace? It’s relatively painless to create ConfigurationSection, ConfigurationElement and ConfigurationElementCollection instances. Those 4 Guys from Rolla have blogged about it, and there are plenty of tutorials using that whole “google” thing.
One thing to note with this approach, is that when you make a change to a web.config, the application is automatically recycled for you.#
UPDATE
You can in fact separate you configuration into separate .config files. You still need to declare the
<section>and<sectionGroup>elements in your master web.config file, but any config section that inherits fromConfigurationSectionsupports aconfigSourceproperty. E.g.:And then you can add a separate
myConfigSection.configfile: