Compiler Error CS0592
Visual Studio 2012
Attribute 'attribute' is not valid on this declaration type. It is valid on 'type' declarations only.
When you define an attribute, you define what constructs it can be applied to by specifying an AttributeTargets value. In the following example, the MyAttribute attribute can be applied to interfaces only, because the AttributeUsage attribute specifies AttributeTargets.Iterface. The error is generated because the attribute is applied to a class (class A).