c# - 错误 : The name 'ConfigurationManager' does not exist in the current context

标签 c# configurationmanager

我在我的 Visual C# 控制台应用程序(Visual Studio 2005 .NET 2.0 框架)中包含了以下语句

using System.Configuration;

并且我在我的应用程序中使用了以下语句:

ConfigurationManager.AppSettings["SomeStringOverHere"];

我尝试构建应用程序,但出现错误: 当前上下文中不存在名称“ConfigurationManager”。

有什么帮助吗?

最佳答案

您需要在项目中引用 System.Configuration.dll 以及“using”语句。

namespace (有时)在程序集中“拆分”。这意味着单个命名空间中的类型实际上位于不同的程序集中。

要确定 BCL 或 FCL 类型属于哪个程序集,请在 MSDN 上查找。如果您查看 help for ConfigurationManager ,您会看到它指定它位于 System.Configuration 程序集中,方法是在靠近顶部的“程序集”处查看。这是您需要从项目中引用的程序集

关于c# - 错误 : The name 'ConfigurationManager' does not exist in the current context,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1751087/

相关文章:

c# - 自定义多线程循环

file-io - ansible include_if_exists

c# - AppSettings 中的更改需要重新启动我的应用程序,我该如何避免?

c# - 无法使用 C# ConfigurationManager

c# - 我写了一个程序,允许两个类到 "fight"。无论出于何种原因,C# 总是获胜。 VB.NET 有什么问题?

c# - 正则表达式匹配没有一些标签的c#

c# - 如何以编程方式分配 .Net 属性?

c# - C# 中是否有现成的 DynamicObject?

c# - ConfigurationManager.AppSettings[Key] 是否每次都从 web.config 文件中读取?

c# - 读取自定义配置部分返回 "Invalid Key Value"