[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 9028
  • Last Modified:

System.Configuration.ConfigurationManager.AppSetting is obsolete

Hi

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!
0
benkyoit
Asked:
benkyoit
1 Solution
 
bruintjeCommented:
Hello benkyoit,

seems strange indeed, but this blog entry has some pointers
source: http://weblogs.asp.net/scottcate/archive/2005/06/13/412248.aspx
-------
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
bruintje
0
 
e1vCommented:
It's easier to access configuration settings using
Properties.Settings.Default.settingsName

Like
string strFilename = Properties.Settings.Default.FileName;
0
 
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!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now