代码之家  ›  专栏  ›  技术社区  ›  TallGuy

无法获取对ConfigurationManager的引用

  •  3
  • TallGuy  · 技术社区  · 15 年前

    我无法让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?)
    

    我绝对肯定 参考 系统配置 在项目中,它肯定在 正确的 项目。DLL版本为2.0.0.0,运行时版本为2.0.50727,与其他版本完全相同。我已尝试删除引用并重新添加它。一个奇怪的事情是,当它显示在项目的引用“文件夹”中时,它显示为“system.configuration”-小写“c”。

    Visual Studio可以找到 system.configuration.configurationsettings(系统配置设置) 类,除了警告它已过时外,没有任何问题。该项目是一个Web项目,代码位于WebControl的代码后面。

    你知道这是怎么回事吗?

    2 回复  |  直到 15 年前
        1
  •  2
  •   Michael Petrotta user3140870    15 年前

    引用中的小写“c”是正常的。你的代码对我很有效。我想知道你给我们展示的片段之外是否还有问题。尝试构建一个全新的解决方案,只需调用参考其配置。证明这是可行的。

        2
  •  13
  •   jnoss    15 年前

    是否添加了对系统程序集system.configuration.dll的引用?

    IIRC应用程序设置位于BCL核心库中,2.0配置管理器位于单独的程序集中。

    推荐文章
    Liam  ·  C#AppSettings数组
    7 年前