For those who switch back and forth between ASP.NET WebForms and WinForms, this review may come in handy.
If you are developing a C # WinForms project, you will find that trying to use ConfigurationManager to get app.config settings will result in the following error:
The name "ConfigurationManager" does not exist in the current context
Since this is enabled by default in ASP.NET projects, this may come as a surprise. Just right-click on the βLinksβ node in your project and look at the β.NETβ tab. Scroll down and you should find System.Configuration . Add this to your project and you should be operational.
Adding a reference to System.Configuration
If you have already added System.Configuration to the use section at the top of the code, now you can use the configuration settings (for example, connection strings) with the code, for example:
con.ConnectionString = ConfigurationManager.ConnectionStrings[sConnection].ConnectionString;
Arsalan Jul 02 '09 at 11:35 2009-07-02 11:35
source share