Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

ConfigurationSettings.AppSettings is obsolete warning

In subservience application i want to use some app.config values for that when I am trying to use following code I get warning message "ConfigurationSettings.AppSettings is obsolete”


After some google search I added namespace “using System.Configuration;” and tried

Following code

string mode = ConfigurationManager.AppSettings["Mode"].ToUpper();

This code is throwing error:

The name 'ConfigurationManager' does not exist in the current context

Solution:

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.
Add a reference to the assembly System.Configuration and use ConfigurationManager.AppSettings["MySetting"] to access the settings!

You’re working code:

 string mode = ConfigurationManager.AppSettings["Mode"].ToUpper();

Share your answer


Share as a guest

Please subscribe me to the CodeChef4U.

By creating your new answer, you agree to the privacy policy and terms of service.