How can I get around the problem "The name 'ConfigurationManager' does not exist in the current context"?

c# configurationmanager entity-framework linq

Question

I'm using VS 2008. My project connects to a database, and ConfigurationManager reads the connection string from App.config. We employ L2E.

Now that I have a basic UI for displaying data from the database for testing/verification purposes, I built a helper project called AndeDataViewer.

In the helper project, I do not wish to add any more Entity Data Models. I have updated a link to all relevant files in the new assistant project.

I ran across the following problem during compilation:

Error   15  The name 'ConfigurationManager' does not exist in the current context   C:\workspace\SystemSoftware\SystemSoftware\src\systeminfo\RuntimeInfo.cs    24  40  AndeDataViewer

I believe I may have to connect a different project setting or configuration related file from the main project to the assistance project. The new helper project doesn't have an App.config file. However, it seems that I am unable to connect to that file in the assistance project. Any thoughts?

1
5
4/30/2010 2:55:05 PM

Accepted Answer

Right-click on your project and choose "Add Reference" Locate the "System.Configuration" component name in the.NET tab and press OK.

"using System.Configuration" instructs the compiler and IntelliSense to look for any classes you use in that namespace. A complete name (System.Configuration.ConfigurationManager) would have to be used each time. In contrast, the namespace or class won't be discovered anywhere if you don't include the reference.

The namespace for the file System.Configuration.dll might theoretically be "Some.Random.Name" since a DLL may have any namespace. They are often the same for consistency and clarity, although there are some exceptions.

24
4/30/2010 3:07:39 PM

Popular Answer

If you encounter a problem when attempting to retrieve the cloud configuration file in your Azure Cloud service,

CloudConfigurationManager does not exist in the current context

on CloudConfigurationManager class, all you have to do is include the Microsoft.WindowsAzure.ConfigurationManager nuget package in your project.

Make sure to add the using statement after that."using Microsoft.Azure" while attempting to access the cloud configuration file in the class.

Hope this is useful!



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow