Tuesday, 15 March 2016

System.Configuration.ConfigurationSettings.AppSettings' is obsolete: '"This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings"

Hi,

Whenever we read values from configuration, the people who worked on earlier versions of .net has a habit of writing the below line of code for reading values from configuration.

string strValue = System.Configuration.ConfigurationSettings.AppSettings["KeyValue"];

The fix is very simple, just add System.Configuration as reference to your project and change ConfigurationSettings to ConfigurationManager. You don't see any warning now.

string strValue = System.Configuration.ConfigurationManager.AppSettings["KeyValue"];

Hope this helps.

--
Happy Coding
Gopinath

No comments:

Post a Comment