【问题标题】:ConfigurationManager not found未找到配置管理器
【发布时间】:2011-05-24 18:44:41
【问题描述】:

我是 VS 3.5 的新手,我正在编写一个控制台应用程序,它需要从 app.config 文件中提取一些键值。

我有:

Imports System.Configuration 

我正在尝试引用ConfigurationManager.AppSettings,但这会产生错误:

名称 ConfigurationManager 未声明

我错过了什么?

【问题讨论】:

    标签: .net app-config configurationmanager


    【解决方案1】:

    我必须在我的 Visual Studio 2019 C# 项目中安装 NuGet 包 System.Configuration.ConfigurationManager

    例如,

    Install-Package System.Configuration.ConfigurationManager -Version 4.7.0
    

    【讨论】:

      【解决方案2】:

      项目 -> 添加引用 -> .NET -> 选择 System.Configuration

      【讨论】:

        【解决方案3】:

        尝试使用 System.Configuration;

        尝试通过选择
        添加参考 项目 -> 添加引用 -> .NET -> 选择 System.Configuration

        现在您可以使用“ConfigurationManager”

        【讨论】:

          【解决方案4】:

          我自己也遇到了这个问题,实际上包含了对 System.Configuration 的引用,但它仍然不显示。

          我必须进入 Build 菜单,选择 Clean,然后重新构建。

          发帖是因为六个月后当我再次看到这个时,我可能会忘记我做了什么......

          【讨论】:

          • 我做了这个,但没用。所以,关闭项目,然后重新打开项目。工作正常。
          【解决方案5】:

          添加对 System.Configuration 的引用:

          菜单栏 -> 项目 -> 添加引用... -> .NET (Tab) -> System.Configuration -> 确定

          【讨论】:

            【解决方案6】:

            确保您引用了程序集System.Configuration.dll

            【讨论】:

            • 是的,感谢您的回复。我最终还是自己想通了!
            猜你喜欢
            • 2020-07-01
            • 2012-04-08
            • 1970-01-01
            • 2015-01-31
            • 1970-01-01
            • 1970-01-01
            • 2013-08-01
            • 1970-01-01
            相关资源
            最近更新 更多