Error 4 The name 'ConfigurationManager' does not exist in the current context
You may get "Error 4 The name 'ConfigurationManager' does not exist
in the current context" error when you copy the code from old version like 1.1.
or 2.0. Microsoft would have given you enough warning by
default when you use ConfigurationSettings in your .NET 2.0
or 3.5. From 4.0 onward it will throw error as "Error 4
The name 'ConfigurationManager' does not exist in the
current context".
Solution is not that
complicated, it is simple and can be resolved in two
steps.
First, if you haven't added the reference
to the System.Configuration then you must add the
reference first.
So from your solution explorer
right click on the Reference and open '.NET' tab and then
locate the 'System.Configuration' option almost at the
bottom.
Once you added the reference or you
already have the reference then add the namespace to use
ConfigurationManager like below,
using
System.Configuration;
or you can use the code
directly like below,
String strConnString =
System.Configuration.ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;