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

Gav*_*ant 9 c# enterprise-library visual-studio-2010

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

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

the*_*ors 11

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


Hal*_*h98 5

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

那么你应该能够包含'using System.ComponentModel;' 在您的项目中,以使您的属性正常工作.