0

I have a code which has the following line(.NET Win Form App)

label1.Text = ConfigurationSettings.AppSettings.Get("Text");

Above works fine but I get a warning that ConfigurationSettings.AppSettings is obsolete and must be replaced by System.Configuration.ConfigurationManager.Appsetting.

The problem is VS says ConfigurationManager is not a type or namespace in System.Configuration.

Im using Vs2019. I have using System.Configuration;

The interesting thing is when I click on potential fixes the only fix Vs suggests is to suppress this warning!

S Nash
  • 2,363
  • 3
  • 34
  • 64
  • is this a netcore app? Net framework app? Which version? – topsail Aug 03 '22 at 19:38
  • Just a .Net Framework Windows form app – S Nash Aug 03 '22 at 19:39
  • 1
    Does this help: https://stackoverflow.com/questions/1274852/the-name-configurationmanager-does-not-exist-in-the-current-context – topsail Aug 03 '22 at 19:44
  • Yes it does .The solution is there. basically I need to manually add a reference to System.Configutartion. Seem to be a flaw in VS but is is the solution. Put this as an answer and I will accept it. – S Nash Aug 03 '22 at 20:34
  • Note that the accepted answer in the link did not help me. – S Nash Aug 03 '22 at 20:35

1 Answers1

0

In my Case having using System.Configuration was not enough. C# could see the obsolete method but not the new one.

I had to add System.Configuration as a reference to make it work.

S Nash
  • 2,363
  • 3
  • 34
  • 64