我根本无法让 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 的代码隐藏中。
有什么想法吗?