错误:使用ConfigurationElementType属性时“不是属性类”

时间:2011-06-23 17:52:25

标签: c# visual-studio-2010 enterprise-library

我正在尝试为企业库5.0的异常处理块创建自定义异常处理程序。据我所知,我需要使用属性启动课程 “[ConfigurationElementType(typeof运算(CustomHandlerData))]”。但是我收到一条错误,指出ConfigurationElementType不是属性类。

有谁知道可能会发生什么?

3 个答案:

答案 0 :(得分:11)

尝试在ConfigurationElementType之后添加关键字Attribute。这不是必需的,但是这可能会让您收到更有用的错误消息...我的猜测是您缺少引用...这始终是EntLib的问题。

答案 1 :(得分:5)

确保在Project-Add References .Net选项卡下将对System.ComponentModel.Compostion或Sytem.ComponentModel.DataAnnotations的引用添加到项目中。

然后你应该可以包含'using System.ComponentModel;'在您的项目中,以使您的属性正常工作。

答案 2 :(得分:0)

将Enterprise Library Shared Library程序集添加到为我工作的项目的引用中。然后,您可以添加使用Microsoft.Practices.EnterpriseLibrary.Common.Configuration;