我在这里看到一篇关于我想做的事情的非常好的帖子,
.net 3.5: To read connectionstring from app.config?
它说要使用 ConfigurationManager 类。我无法引用 ConfigurationManager 类。
如果我查看我正在使用的 system.dll(v2.0.50727),则没有 ConfigurationManager 类。
我使用的是 VS 2008,我的项目设置为编译为 .NET 3.5。
如果我这样做,
string test = System.Configuration.ConfigurationManager.AppSettings["test"];
我收到消息“错误 182 类型或命名空间名称‘ConfigurationManager’在命名空间‘System.Configuration’中不存在(是否缺少程序集引用?)”
有什么想法吗?
最佳答案
ConfigurationManager
是 System.Configuration
命名空间的一部分。默认情况下,项目中未引用它,因此请从 GAC 添加对 if 的引用。
关于c# - ConfigurationManager - 如何在 .NET 3.5 中使用连接字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3358204/