How to avoid the "ConfigurationManager" name error in the current context?

I am using VS2008. I have a database related project, and the connection string is read from App.config via ConfigurationManager. We use L2E.

Now I have added the AndeDataViewer helper project to have a simple interface for displaying data from the database for testing / verification purposes.

I do not want to create another set of entity data models in a supporting project. I just added all the related files as a link in a new helper project.

When compiling, I received the following error:

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

I think I might need to add another link to the project / configuration of the linked file with the supporting project from the main project? There is no App.config file in the new helper project. But it looks like I can’t add the file link to the helper project. Any ideas?

+4
source share
3 answers

In your project, right-click Add Link ... On the .NET tab, find the component name "System.Configuration" and click "OK."

"using System.Configuration" tells the / IntelliSense compiler to search this namespace for any classes that you use. Otherwise, you will have to use the fully qualified name (System.Configuration.ConfigurationManager) each time. But if you do not add the link, this namespace / class will not be found anywhere.

Note that a DLL can have any namespace, so the System.Configuration.dll file can theoretically have a namespace of "Some.Random.Name". For clarity / consistency, they are usually the same, but there are exceptions.

+19
source

If you are trying to access the cloud configuration file in your Azure Cloud service and receive an error message

CloudConfigurationManager does not exist in the current context

on CloudConfigurationManager , all you have to do is add the Microsoft.WindowsAzure.ConfigurationManager nuget project to the project.

And then make sure you include the using "using Microsoft.Azure" statement in the class in which you are trying to access the cloud configuration file.

Hope this helps!

+2
source

I think you are missing a link to System.Configuration.dll or a sentence using System.Configuration

0
source

Source: https://habr.com/ru/post/1308473/


All Articles