C# .NET 4.5 Framework 上不存在 ConfigurationManager 类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12947179/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 01:02:56  来源:igfitidea点击:

ConfigurationManager Class not exist on .NET 4.5 Framework

c#.net.net-4.5

提问by Hatem

I just start working with .NET Framework 4.5 of C#. Am using Windows Form Application. I have do the needed imports such as :

我刚开始使用 C# 的 .NET Framework 4.5。正在使用 Windows 窗体应用程序。我已经做了所需的进口,如:

using System.Configuration;

But actually the ConfigurationManager class seems that it is not exits. I have tried to use ConfigurationSettings instead , but Visual Stdio telling me that it is obsolete and replaced by ConfigurationManager !

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

This is chunk of code related to the problem :

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

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

So , could you please help me ?

那么,你能帮帮我吗?

回答by Ekk

  1. Make sure that you add System.Configuration.dllto the project. If you already added it, try to remove and add it again.
  2. Put the cursor on ConfigurationManagerthen press ctrl+., and see what it suggests you.
  1. 确保您添加System.Configuration.dll到项目中。如果您已经添加了它,请尝试删除并再次添加。
  2. 把光标放在上面,ConfigurationManager然后按ctrl+ .,看看它给你什么建议。

回答by Hatem

It is because of reference , I just restarted the project after adding the reference and it is working OK :)

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

回答by Ramendra

ConfigurationManager is present in System.Configuration namespace but it need System.Configuration assembly in your project.

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

回答by Shalom Segev

RightClick on project -> Add-> Reference...-> Assemblies-> Framework Select the System.Configuration (checked) Should solve the problem.

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

回答by Chamath Viduranga

If you are unable to find the reference here is the correct path

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

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

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

Go to the Add reference and select the browser option and go to the above link. Then you can add the System.Configuration.dll

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