I got the following warning
'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: '"This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings"'
How do you fix it?
I got the following warning
'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: '"This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings"'
How do you fix it?
It's simple as mentioned above, just add a reference "System.Configuration" for the application, and within the code you can add "using System.Configuration" to the top of the code and use "ConfigurationManager.AppSettings[""]" where you need it.
Just in case someone else was looking for the Add Reference option to achieve the accepted answer in Visual Studio 2010. (I had to do this in updating a VB project).
In Visual Studio 2010:
From System.Configuration.ConfigurationSettings.AppSettings("name") to System.Configuration.ConfigurationManager.AppSettings
Without adding the reference IntelliSense won't suggest ConfigurationManager when you type it, and that's because it doesn't have a reference to be aware of where it is. Which is also why you will get errors when you updated the line of code according to their suggestion.
After adding the reference
using System.Configuration;
at the top of the class. Still the same warning remains.In Code Behind:
Instead of
ConfigurationSettings.AppSettings["ConnectionString"]
Use
ConfigurationManager.AppSettings["ConnectionString"]
By Default the System.configuration Dll will be added in your project.
In Web.config or App.config:
as its a warning i dont think it matters unless you have turned off a treat warnings as errors setting
add a reference to System.Configuration
all you have to do is to update to the latest code so where you used
ConfigurationSettings.AppSettings[""] change to ConfigurationManager.AppSettings[""]
and this should work
the System.configuration DLL exsit in c:\Windows\Microsoft.NET\Framework\v2.0.50727\
I also face same issue, sometimes the assembly reference not loaded properly or if you are using multiple projects it give problems sometimes. You just add reference to assembly. Right Click>Add Reference>.Net>System.configuration> Click OK You can see now there are many configuration options available choose ConfigurationManager.AppSetting["Con"].ToString();
Build and Smile :)