attributes
-
Hi, I've defined an attribute type which is used on classes. I've written code that loads an assembly, iterates all the types defined in the assembly and search for types that have that attribute. This all works fine and in the debugger i can see that it is finding the attribute on the class. However I can't cast it from a generic System.Attribute to my own custom attribute type. If I use the Type.GetCustomAttributes overload that takes an attribute type as an argument and pass it my custom attribute type it doesn't find any. The debugger shows the attributes that I'm finding as being my custom type when i call GetCustomAttributes with no type. Any ideas? Code snippet: attributes = type.GetCustomAttributes(false); if(attributes.Length != 0) { // check to see if it's what we are after foreach(System.Attribute attribute in attributes) { Transformer transformer = attribute as Transformer; if(transformer != null) transformers.Add(new DataTransformer(transformer.ID,transformer.DisplayName,transformer.FileExtension,assembly,type)); } } any explicit casts also fail. Transformer is my custom attribute type and the debugger shows the attribute to be of that type.