I have a solution with about 10 projects with read-only config. They are web applications, windows services, console apps, etc. All projects except for one are on the same server. Each project has 3 environments – dev, test, and production. So there are 30 different sets of configuration, each one with a decent number of settings. It’s cumbersome to keep the config consistent across every app and environment.
I’ve noticed most of the configuration is common across each project, so I was thinking it would be good to centralize the config in some way. I read somewhere that a WCF service might be a good approach. I thought maybe a library containing a hard-coded static class might actually work OK – despite having to compile to change config. Ideally the config should come out of an actual .config file.
How would you go about centralizing config for multiple projects?
If you want to maintain the standard configuration interface, take a look at the ProtectedConfigurationProvider. This provider lets you store your configuration data outside of a standard configuration file, encrypt it however you like, or redirect requests for configuration in any way you see fit:
The beauty of this approach is that nothing changes in your existing applications. They don’t need to know where their configuration is stored. The retrieval of configuration data is isolated in the provider. You can store it in a central file, store it in a database, or access it via a web service. If you change your mind, you only have to update your provider. Everything else stays the same.