The Name 'Configurationmanager' Does Not Exist in the Current Context

The name 'ConfigurationManager' does not exist in the current context

Ok.. it worked after restarting the VSTS. The link suggested the solution for the same problem. Wish i could have seen it before. :)

the name configurationmanager does not exist in the current context

You should install System.Configuration.ConfigurationManager package. So please try to execute the following command:

Install-Package System.Configuration.ConfigurationManager

Correction

Since you are working on Mac, I don't know If you can run the above command. This definitely works inside Visual Studio / Windows. So please follow the instructions found here for adding a dependency to the package mentioned above.

How to avoid The name 'ConfigurationManager' does not exist in the current context error?

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

"using System.Configuration" tells the compiler/IntelliSense to search in that namespace for any classes you use. Otherwise you would have to use the full name (System.Configuration.ConfigurationManager) every time. But if you don't add the reference, that namespace/class will not be found anywhere.

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

The name 'ConfigurationManager' does not exist in the current context

Which version of .NET Framework and Visual Studio are you using?

ConfigurationManager is only available in .NET 2 and above. If you are using .NET Framework 1.x and Visual Studio 2002/2003, you won't be able to use this class at all.

http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx

Click "Other versions" link in the top of this page and you will see all versions it supports.

Error: The name 'ConfigurationManager' does not exist in the current context

You need to reference System.Configuration.dll in your project as well as the "using" statement.

Namespaces are (sometimes) "split" across assemblies. That means that types in a single namespace are actually in different assemblies.

To determine which assembly a BCL or FCL type is in, look it up on MSDN. If you look at the help for ConfigurationManager, you'll see that it specifies that it's in the System.Configuration assembly by looking near the top at "Assembly". This is the assembly you need to reference from your project

How to fix the name configurationmanager does not exist in the current context

Add a using statement at the top of your cs code file:

using System.Configuration;

Or fully qualify the reference:

private static string _connStr = 
System.Configuration.ConfigurationManager.ConnectionStrings["MESConnection"].ConnectionString;

EDIT

I see you haven't in fact referenced the correct assembly. You need to reference System.Configuration.dll not System.Configuration.Install.dll

Also the usual way to reference a .NET assembly in Visual Studio is to right-click on the References node in Solution Explorer and choose Add Reference...

Sample Image

How to solve type or namespace name 'ConfigurationManager' does not exist in the namespace 'System.Configuration' error in .net standard?

I solved the issue by adding Microsoft.Extensions.Configuration to the project from the NuGet package manager.

c# Appsettings giving error: The name 'ConfigurationManager' does not exist in the current context

To expand a bit, you will need to add a reference to System.Configuration.dll to get this to work. It's kind of misleading because the System.Configuration namespace also exists inside the base System.dll, and holds some far lesser used objects like SettingsContext. As a result, it seems like it really ought to work, but it doesn't. It is really confusing, and currently one of those obtuse gotchas in the .NET framework.

Fortunately, System.Configuration.dll is in the .NET base framework, so you only need to add a reference by right-clicking on the References folder in your project, clicking Add Reference, and then finding System.Configuration under the .NET tab.

After it has been imported into your project, don't forget to add using System.Configuration to the top of the code file you intend to use ConfigurationManager in.



Related Topics



Leave a reply



Submit