Postsharp重复属性?

时间:2010-04-02 15:03:09

标签: c# aop postsharp

有谁可以解释为什么我收到这个编译错误?

Duplicate 'Rad.Core.Aop.MethodArgumentValidation' attribute E:\Scripting\Rad.Core\Properties\AssemblyInfo.cs

这是代码:

[assembly: Rad.Core.Aop.MethodArgumentValidation(AttributeTargetTypes="Rad.*", AttributePriority=1)]
[assembly: Rad.Core.Aop.MethodArgumentValidation(AttributeTargetTypes = "Rad.Core.Aop.*", AttributePriority = 2, AttributeExclude=true)]

以下是方面的声明:

[Serializable]
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property)]
[MulticastAttributeUsage(MulticastTargets.Method, AllowMultiple=true)]
public class MethodArgumentValidationAttribute : OnMethodInvocationAspect
{ ... }

看起来就像我正在关注此示例:http://www.sharpcrafters.com/blog/post/multicasting-of-custom-attributes.aspx

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

我认为错误来自C#编译器。编译器不了解MulticastAttributeUsageAttribute。但它确实理解了AttributeUsageAttribute。确保使用AttributeUsageAttribute允许重复。