无法获取对ConfigurationManager的引用

Tal*_*Guy 3 .net configurationmanager visual-studio-2005

我根本无法让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?)
Run Code Online (Sandbox Code Playgroud)

我绝对,积极有一个参考System.Configuration项目,它肯定是在正确的项目.DLL版本为2.0.0.0,运行时版本为2.0.50727 - 与其他版本完全相同.我试过删除引用并重新添加它.奇怪的是,当它显示在项目的References'文件夹'中时,它显示为'System.configuration' - 带有小写'c'.

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

有什么想法在这里发生了什么?

jno*_*oss 13

您是否添加了对System Assembly System.Configuration.dll的引用?

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