我在我的 Visual C# 控制台应用程序(Visual Studio 2005 .NET 2.0 框架)中包含了以下语句
using System.Configuration;
并且我在我的应用程序中使用了以下语句:
ConfigurationManager.AppSettings["SomeStringOverHere"];
我尝试构建应用程序,但出现错误: 当前上下文中不存在名称“ConfigurationManager”。
有什么帮助吗?
最佳答案
您需要在项目中引用 System.Configuration.dll 以及“using”语句。
namespace (有时)在程序集中“拆分”。这意味着单个命名空间中的类型实际上位于不同的程序集中。
要确定 BCL 或 FCL 类型属于哪个程序集,请在 MSDN 上查找。如果您查看 help for ConfigurationManager ,您会看到它指定它位于 System.Configuration 程序集中,方法是在靠近顶部的“程序集”处查看。这是您需要从项目中引用的程序集
关于c# - 错误 : The name 'ConfigurationManager' does not exist in the current context,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1751087/