Anatoly Lubarsky Logo
programming, design, integration, games, music

New in .NET 2.0: ConfigurationManager.AppSettings Property

Microsoft now disapproves of the use of ConfigurationSettings (in the System.Configuration namespace) for the retrieval of application and machine configuration settings. The .Net 2.0 now exposes a ConfigurationManager class that "replaces" ConfigurationSettings.


I guess this one should soon be a FAQ (or already is) but I just wanted to write it down. Suppose, you convert a simple 2003 web project to 2005. You compile it. Now you get a warning on ConfigurationSettings.AppSettings Property:


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


I want to describe what happens since the warning message is not descriptive enough, imho, especially for people who are not familiar with .NET 2.0 yet.


What to do in order to use ConfigurationManager class ? System.Configuration.dll - ensure you add a reference to this assembly. In .NET 2.0 all configuration functionality is in this separate assembly now. Please note: you can find System.Configuration namespace also in System.dll assembly, for example ConfigurationSettings is still there, so it can cause some confusion.


Unrelated: strange that in VS 2005 solution tree - System.configuration reference visually has "c" in lower case. Why ?


Related Posts:

Sunday, November 06, 2005 2:24 AM

Comments

# re: .Net 2.0: ConfigurationManager.AppSettings
Anatoly - I'm not following you on this. Do you just need to add System.configuratino with the little c and it will work?

11/7/2005 11:35 PM by Bill

# re: .Net 2.0: ConfigurationManager.AppSettings
Bill: The code with old ConfigurationSettings class under System.Configuration (under System.dll !) will still compile, but will give a warning that it is obsolete.

i.e. need to use new class ConfigurationManager (now this one is under System.Configuration, but the assembly is different -- System.Configuration.dll -- you have to provide a reference to it to make it work)

My point here is that the warning is not informative and it is not obvious you have to add a reference since you already have System.Configuration under System.dll.

Now, when you add a reference there is a minor bug in VS that visually you see as if it is added as System.configuration.dll in the project tree.




11/7/2005 11:42 PM by Anatoly Lubarsky

# re: New in .NET 2.0: ConfigurationManager.AppSettings Property
The solution is to add the referance manually. In the Add Reference dialog, scroll down in .NET tab and find System.Configuration. When you add this reference System.Configuration.ConfigurationManager will be available.

4/10/2006 7:48 AM by Krishan Ariyawansa

# re: New in .NET 2.0: ConfigurationManager.AppSettings Property
Krishan: Why don't you read the post: "System.Configuration.dll - ensure you add a reference to this assembly."

4/10/2006 9:01 AM by Anatoly Lubarsky

# re: New in .NET 2.0: ConfigurationManager.AppSettings Property
I've added a reference to the System.Configuration and I still find it does not know about the ConfigurationManager (indeed it is not listed in intellisence either)

8/15/2006 12:35 PM by Paul

# re: New in .NET 2.0: ConfigurationManager.AppSettings Property
Paul: Besides the reference you have to add using directive at the beginning of the file.

8/15/2006 8:28 PM by Anatoly Lubarsky

Login

Subscribe via RSS

Article Categories

.Net Framework
ASP.NET Tips
C# Win32 API
HTML, CSS, Web
Javascript Tips
MSSQL Tips
System
System.Net
WebServices

Archives

(02) January, 2018
(01) June, 2013
(03) March, 2013
(02) February, 2013
(01) July, 2012
(01) April, 2012
(01) September, 2011
(01) August, 2011
(03) May, 2011
(01) March, 2011
(02) December, 2010
(01) November, 2010
(01) October, 2010
(01) June, 2010
(01) May, 2010
(02) March, 2010
(01) January, 2010
(02) December, 2009
(03) September, 2009
(03) August, 2009
(09) July, 2009
(04) June, 2009
(03) May, 2009
(02) April, 2009
(03) March, 2009
(02) February, 2009
(02) January, 2009
(05) December, 2008
(04) November, 2008
(06) October, 2008
(04) September, 2008
(07) August, 2008
(04) July, 2008
(05) June, 2008
(07) May, 2008
(05) April, 2008
(03) March, 2008
(02) February, 2008
(03) January, 2008
(03) December, 2007
(05) November, 2007
(05) October, 2007
(07) September, 2007
(13) August, 2007
(11) July, 2007
(14) June, 2007
(16) May, 2007
(14) April, 2007
(10) March, 2007
(14) February, 2007
(20) January, 2007
(15) December, 2006
(12) November, 2006
(11) October, 2006
(13) September, 2006
(13) August, 2006
(12) July, 2006
(11) June, 2006
(12) May, 2006
(22) April, 2006
(30) March, 2006
(13) February, 2006
(14) January, 2006
(19) December, 2005
(17) November, 2005
(17) October, 2005
(17) September, 2005
(12) August, 2005
(14) July, 2005
(09) June, 2005
(15) May, 2005
(12) April, 2005
(21) March, 2005
(11) February, 2005
(12) January, 2005
(19) December, 2004
(13) November, 2004
(12) October, 2004
(15) September, 2004
(09) August, 2004
(25) July, 2004
(23) June, 2004
(31) May, 2004
(21) April, 2004
(16) March, 2004
(09) February, 2004
(06) January, 2004
(02) December, 2003
(01) November, 2003

Post Categories

.Net and C#
Android
Antispam
App. Development
Architecture
ASP.NET
Blogging
Deprecated Projects
Facebook Platform
Fun
Google
iOS
Javascript
Misc.
MSSQL
Music
My Games
Performance
Roller
Social Networks
Tools
Visual Studio
Web 2.0
WebServices

About Me

linkedin Profile
Recs
Who am I

My Sites

Billy Beet
x2line blogs