Possible Duplicate:
Specify required base class for .NET attribute targets
I want to specify that my custom attribute only be valid on certain types (based on interface or base class).
Like this:
How can I do that?
It sounds like you want to create an Attribute
which can only be applied to certain types in much the way that AttributeUsage
can only be applied to types deriving from Attribute
. Introducing this type of custom restriction is simply not possible. The particular error you're seeing is not because of a custom restriction, it's one that's simply hard wired into the compiler itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With