Attributes not inheriting RRS feed

  • Question

  • I have an attribute devined as:

    [AttributeUsage(AttributeTargets.Class, Inherited=true, AllowMultiple=true)]

    public class OperationAttribute : Attribute


    public class ChildOperationAttribute : OperationAttribute



    then a base class defined with one attribure as:


    public abstract class SecuredBase : Base


    and another class that inherits from it and defines a second attribute:


    public class SecuredChild : SecuredBase



    In .NET 2003 the code:

    return (OperationAttribute[]) type.GetCustomAttributes( typeof(OperationAttribute), true )

    would return both CanAccess and CanAdmin.


    In .NET 2008 the came code only returns CanAdmin.

    If no attributes are defined in the child class, then CanAccess is returned.

    WHy is this?  I really need both attributes returned.

    Thursday, May 15, 2008 6:19 PM


All replies