System.Configuration.ConfigurationManager.AppSetting is obsolete

Posted on 2006-05-18
Last Modified: 2008-05-12

I used VS2005. When i access a value in the config file, i write the code like this:

string strFilename = System.Configuration.ConfigurationSettings.AppSettings["FileName"].ToString();

But when i built the project, the warning appear like this:

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

I found this problem in MSDN and i used System.Configuration.ConfigurationManager. But the new error happen: ConfigurationManager is not in System.Configuration. What can i do? How can i fix this problem. Thanks!
Question by:benkyoit
    LVL 44

    Accepted Solution

    Hello benkyoit,

    seems strange indeed, but this blog entry has some pointers
    The Original System.Configuration.ConfigurationSettings class is found in the System.dll assembly. There is a new assembly with all the new ConfigurationManager classes as System.Configuration.dll. Before using the ConfigurationManager class, you must first set a reference to the new System.Configuration.dll.

    hope this helps a bit
    LVL 6

    Expert Comment

    It's easier to access configuration settings using

    string strFilename = Properties.Settings.Default.FileName;

    Author Comment

    Thanks bruintje!
    I fixed this problem but i want to ask you if i used the obsolete code, beside warning during the building, have any other error when excute. Thank you very much!

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    In one of my recent projects, I was working with IP cameras, I need to take some pictures from the camera and do some processing on it. The first step, was to retrieve the image from camera into Image object. So that it can be displayed or …
    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    This video discusses moving either the default database or any database to a new volume.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now