For anyone who switches back and forth between developing ASP.NET WebForms and WinForms, this tip may come in handy.
If you are developing in a C# WinForms project, you will find that attempting to use a ConfigurationManager to get at your app.config settings will result in the following error:
The name 'ConfigurationManager' does not exist in the current context
Since this is included by default in ASP.NET projects, this may come as a surprise. Just simply right-click on the References node in your project and look on the .NET tab. Scroll down and you should find System.Configuration. Add this to your project and you should be up and running.
Provided you have already added System.Configuration to the using section at the top of your code, you should now be able to use config settings (such as connection strings) with code such as the following:
con.ConnectionString = ConfigurationManager.ConnectionStrings[sConnection].ConnectionString;
Filed under: Development