Blog Indiana 2008

‘ConfigurationManager’ is not a member of ‘Configuration’

At the risk of appearing to be an idiot, I’m going to blog this so I don’t forget. Especially since it bit me twice *in the same project*. Oops.

In .NET 2.0, the old method of getting information from the app.config has been depreciated. The new method is:


ConfigurationManager.ConnectionStrings.Item(YourDB).ConnectionString

For this to work, though, you need to remember to add a reference to System.Configuration. This needs to be done for each project in the solution that uses it. Thankfully I figured out that last bit pretty quickly.

Posted on March 30, 2007 in .NET.    

One Comment

  1. Daniel said:

    One thing I can’t appreciate about ConfigurationManager is that if I have a data layer with a connection string that is accessed in that layer by ConfigurationManager, if I reference the data layer assembly in a services layer, the data layer code can’t find the connection string because it’s looking in the services layer’s config area. Having to reference the connection string twice seems to me like it’s jumping the wall, even though I know it’s really just one \bin\.

(Comments are moderated.)