'System.Configuration.ConfigurationSettings.AppSettings' is obsolete

Viewed 104370

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?

12 Answers

example:

replace

string smtpServer = System.Configuration.ConfigurationSettings.AppSettings["EmailServer"];

with

string smtpServer = ConfigurationManager.AppSettings["EmailServer"];

also make sure on the top of the case you add:

using System.Configuration;

I had the same problem in a C# project and I fixed it by writing appSettings instead of AppSettings in the XML file (camelCase expected) in the tag

<appSettings>
  <add key="myKey" value="my Value"/>
<appSettings>

After all C# is case sensitive

Related