A place to keep my thoughts on programming

March 10, 2006 .net

configSource attribute

I’ve been using the new <connectionStrings> tag for .NET 2.0 to store my DB config. I used to just have a custom <configSections> handler for it before. But hey, it’s built in, let’s use it. Now i’m putting NUnit in a bunch of projects so they all need to have app.config files. But i don’t want them to each have a copy of the strings. Just means sooner or later things get screwed up. Not to mention that having the config file in the source control tree means that my local config gets checked in and i have to modify them on every machine to match environments.

For <appSettings> and my own config handlers, I always had a file attribute to externalize them into a central configuration space. Except <connectionStrings> doesn’t have file, only configSource. At first glimpse it looks like the same thing. Sure, it adds some cool stuff, like being able to reload on change, which file couldn’t. But the price you pay is that the new file has to be in the same directory or a subdirectory. So much for using one config for multiple apps. I may be overlooking something, but I can’t really find any good reference on the subject.

Leave a comment