'ConfigurationManager' is not a member of 'Configuration'.

wsturdev
wsturdev used Ask the Experts™
on
I am working in Visual Studio 2005 and have 2 web apps.  Both of them have this in the VB Code Behind:
        Dim connectionString As String = ConfigurationSettings.AppSettings("theConnectionString").Replace("ClientName", Session("Client"))

ConfigurationSettings.AppSettings keeps getting a warning, so taking the warning suggestion I recoded it as:
        Dim connectionString As String = System.Configuration.ConfigurationManager.AppSettings("theConnectionString").Replace("ClientName", Session("Client"))

In the first app, it works without an error.

But in the second app, I get this error:
'ConfigurationManager' is not a member of 'Configuration'.

I cannot figure out what is basically different between the two apps.  Why is this happening?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Technical Architect
Commented:
You have to add referece to the assembly "System.configuration"  to your project to enable ConfigurationManager.

Author

Commented:
At first I didn't knwo what you meant, because I am dense...  but then got it.  Thanks!!

Commented:
I have multiple projects in a solution. I had to right click on each project and add a reference to System.Configuration to each. Then I had to specify System.Configuraiton.ConfigurationManager.AppSettings("var")
Configuraiton.ConfigurationManager.AppSettings("var") alone did not work at removing the error.
I did not need the Imports System Configuration statement on the individual vb pages after doing this.
Aaron JabamaniTechnical Architect

Commented:
You have to add "Imports" as well in each page.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial