.net 找不到配置管理器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4431034/
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
ConfigurationManager not found
提问by DeveloperM
I am new to VS 3.5 and I am writing a console app that needs to pull some key values from the app.config file.
我是 VS 3.5 的新手,我正在编写一个控制台应用程序,它需要从 app.config 文件中提取一些关键值。
I have:
我有:
Imports System.Configuration
and I am trying to reference ConfigurationManager.AppSettingsbut this generates an error:
我正在尝试引用,ConfigurationManager.AppSettings但这会产生错误:
Name ConfigurationManager is not declared
名称 ConfigurationManager 未声明
What am I missing?
我错过了什么?
回答by Philip Fourie
Make sure you have a reference to the assembly System.Configuration.dll
确保您有对程序集的引用 System.Configuration.dll
回答by JerryGoyal
回答by Tim
I had this problem myself and actually included the reference to System.Configuration, and it STILL wouldn't show up.
我自己也遇到了这个问题,实际上包含了对 System.Configuration 的引用,但它仍然不会出现。
I had to go to the Build menu, select Clean, and then rebuild.
我必须转到“构建”菜单,选择“清理”,然后重新构建。
Posting because in six months when I see this again I'll probably forget what I did...
发帖是因为六个月后当我再次看到这个时,我可能会忘记我做了什么......
回答by Harsha
Try using System.Configuration;
OR
Try to add reference by selecting
Project -> Add References -> .NET -> select System.Configuration
尝试使用 System.Configuration;
或
尝试通过选择
Project -> Add References -> .NET -> 选择 System.Configuration 添加引用
now you can use "ConfigurationManager"
现在您可以使用“ConfigurationManager”
回答by Qsiris
Add the reference to System.Configuration:
添加对 System.Configuration 的引用:
Menu Bar -> Project -> Add Reference... -> .NET (Tab) -> System.Configuration -> OK
菜单栏 -> 项目 -> 添加引用... -> .NET (Tab) -> System.Configuration -> OK
回答by MTMDev
I had to Install NuGet package System.Configuration.ConfigurationManagerin my Visual Studio 2019 C# project.
我必须System.Configuration.ConfigurationManager在我的 Visual Studio 2019 C# 项目中安装 NuGet 包。
E.g.,
例如,
Install-Package System.Configuration.ConfigurationManager -Version 4.7.0


