You are not Logged in
Would you like to Login or Register

Today is: 10 February 2012
Check this months hot topics

Referencing ConfigurationManager

When I started working in VS2005, I assumed that accessing your AppSettings would be the same as it was in VS2003. On compiling, the IDE served up the following warning.

'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'

Old way of accessing AppSettings

string mySetting = ConfigurationSettings.AppSettings["mySetting"];

New way of accessing AppSettings

string mySetting = ConfigurationManager.AppSettings["mySetting"];

So I changed my code accordingly, but the project wouldn't compile. It turns out that you need to add a reference to System.Configuration to the project, rather than simply adding it with a using statement. This can be done as follows.

Add a reference to System.Configuration by clicking Project -> Add Reference... and searching through the .NET components for System.Configuration

kick it on DotNetKicks.com del.icio.us digg Mister Wong YahooMyWeb Reddit Furl Spurl blogmarks
Barrington Haynes Skype
Author : Barrington Haynes
Published : 14 June 2006

I have nothing more to say :-)

Add Comment

Enter your comment below and it will be submitted for moderation.

Your Name

Add Tag

Please enter tags for this article, seperated by semi-colon ;

View Tag's by : # articles | # views