【问题标题】:ConfigurationManager Class not exist on .NET 4.5 Framework.NET 4.5 Framework 上不存在 ConfigurationManager 类
【发布时间】:2012-10-18 04:35:18
【问题描述】:

我刚开始使用 C# 的 .NET Framework 4.5。我正在使用 Windows 窗体应用程序。我已经完成了所需的导入,例如:

using System.Configuration;

但实际上 ConfigurationManager 类似乎没有退出。我尝试改用 ConfigurationSettings ,但 Visual Stdio 告诉我它已过时并被 ConfigurationManager 取代!

这是与问题相关的代码块:

Int32.Parse StartingMonth = int.parse(ConfigurationManager.AppSettings["StartingMonthColumn"]);

那么,你能帮帮我吗?

【问题讨论】:

  • 您是否已将参考添加到 System.Configuration 程序集?
  • 添加了引用,这也没有解决问题!

标签: c# .net .net-4.5


【解决方案1】:
  1. 确保将System.Configuration.dll 添加到项目中。如果您已添加它,请尝试将其删除并重新添加。
  2. 将光标放在ConfigurationManager 上,然后按ctrl+.,看看它会给你什么建议。

【讨论】:

  • on #1 - 在您的项目下,右键单击引用,单击添加引用,System.Configuration.dll 应该在第一个选项卡“.NET”上可用
【解决方案2】:

右键单击项目->添加->参考...->程序集->框架 选择 System.Configuration(选中) 应该能解决问题。

【讨论】:

  • 这对我有用
【解决方案3】:

ConfigurationManager 存在于 System.Configuration 命名空间中,但它需要在您的项目中使用 System.Configuration 程序集。

【讨论】:

    【解决方案4】:

    这是因为引用,我只是在添加引用后重新启动了项目,它工作正常:)

    【讨论】:

      【解决方案5】:

      如果在这里找不到参考是正确的路径

      “C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a”

      转到添加参考并选择浏览器选项并转到上面的链接。然后你可以添加 System.Configuration.dll

      【讨论】:

        猜你喜欢
        • 2013-09-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-09-02
        • 2013-09-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多