System.Configuration.ConfigurationManager.AppSetting is obsolete


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!
Who is Participating?
bruintjeConnect With a Mentor Commented:
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
It's easier to access configuration settings using

string strFilename = Properties.Settings.Default.FileName;
benkyoitAuthor Commented:
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!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.