【发布时间】:2014-04-02 01:23:45
【问题描述】:
我正在尝试使用由 Visual Studio 2010 中的 C# 程序中的 App.config 文件指定的值,基于此帖子的“已接受答案”中指定的方向:Custom app.config Config Section Handler
我的代码文件是using System.Configuration,我正在尝试创建以下内容:
public class ConnectionCollection : ConfigurationElementCollection {
//code here
}
public class ConnectionElement : ObjectConfigurationElement {
//code here
}
但是,错误消息显示找不到 ConfigurationElementCollection、ObjectConfigurationElement 和 ConfigurationElement。我做错了什么?
【问题讨论】:
-
你使用的是哪个版本的框架?
-
Visual Studio 2010 中的 c#.net
-
那是开发环境版本,不是你项目中使用的框架版本。 VS2010 默认为 4.0。另外,您是否添加了对 System.Configuration 程序集的引用?
-
是的,我添加了对 System.Configuration 的引用,但它仍然不起作用。目标框架是 .NET 框架 4。
-
这是什么
ObjectConfigurationElement?引用程序集后ConfigurationElementCollection应该没问题,但我没有看到任何ObjectConfigurationElement。仅限ConfigurationElement:msdn.microsoft.com/en-us/library/…
标签: c# .net xml visual-studio-2010 app-config