.net - 无法获得对 ConfigurationManager 的引用

标签 .net visual-studio-2005 configurationmanager

我根本无法让 Visual Studio 2005 找到 System.Configuration.ConfigurationManager 类。这是代码:

using System.Configuration;

...

x = ConfigurationSettings.AppSettings["MySetting"]
// The name 'ConfigurationManager' does not exist in the current context

x = System.Configuration.ConfigurationManager.AppSettings["MySetting"]
// The type or namespace name 'ConfigurationManager' does not exist in the
// namespace 'System.Configuration' (are you missing an assembly reference?)

我绝对肯定在项目中有对 System.Configuration 的引用,它肯定在 中。右 项目。 DLL 版本为 2.0.0.0,运行时版本为 2.0.50727 - 与所有其他版本完全相同。我尝试删除引用并重新添加它。一件奇怪的事情是,当它显示在项目的引用“文件夹”中时,它显示为“System.configuration” - 带有小写的“c”。

Visual Studio 可以找到 System.Configuration.ConfigurationSettings 类,除了它已过时的警告之外没有任何问题。该项目是一个 Web 项目,代码位于 WebControl 的代码隐藏中。

任何想法这里发生了什么?

最佳答案

您是否添加了对系统程序集 System.Configuration.dll 的引用?

IIRC AppSettings 在 BCL 核心库中,2.0 ConfigurationManager 在单独的程序集中。

关于.net - 无法获得对 ConfigurationManager 的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1659061/

相关文章:

c# - 如果它们都使用 PascalCasing 命名,如何区分属性和常量?

c# - 需要避免数字签名公共(public)证书 BinarySecurityElement 被 mtom 编码

visual-studio-2005 - 如何在 Visual Basic 2005 Express 中禁用 'Just My Code'?

c# - ConfigurationManager 类不可用

c# - 在类库中找不到 ConfigurationManager

c# - 过滤 PropertyGrid 中显示的属性

c# - 是否可以在不使用编译指令的情况下检测主应用程序线程是否作为 Windows 服务运行?

c# - 如何从自定义成员资格提供程序中处理自定义对象

visual-studio - Visual Studio 中的选项卡式文档 - 可以显示比文件名更详细的信息吗?

c# - 单元测试在 Web 应用程序使用的类库中使用配置管理器的方法