Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'System.Configuration.ConfigurationSettings.AppSettings' is obsolete

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?

like image 267
001 Avatar asked Oct 18 '10 13:10

001


People also ask

How do I override ConfigurationManager appSettings?

It appears there is a way to do this in . NET 3.5 by setting the allowOverride attribute in the appSettings definition section of machine. config. This allows you to override the entire section in your own app.

Can I use ConfigurationManager in .NET core?

ConfigurationManager was added to support ASP.NET Core's new WebApplication model, used for simplifying the ASP.NET Core startup code.

What is the use of ConfigurationManager appSettings?

Gets the AppSettingsSection data for the current application's default configuration.

Are appSettings cached?

It is important to realize that the entire <appSettings> section is read, parsed, and cached the first time we retrieve a setting value.


2 Answers

Add a reference to the assembly System.Configuration.

Then at the top (assuming C#) using System.Configuration (Imports System.Configuration in VB.NET).

Use ConfigurationManager.AppSettings["MySetting"] to access the settings!

like image 200
Mike Cheel Avatar answered Sep 25 '22 15:09

Mike Cheel


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

like image 43
stack72 Avatar answered Sep 21 '22 15:09

stack72