By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,089 Members | 1,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,089 IT Pros & Developers. It's quick & easy.

Reflection / GetCustomAttributes problem

P: n/a

I ran into a strange problem a few days ago; when i execute the code at
the bottom of this message GetCustomAttributes() isn't returning
anything. Although the attributes are there... The code is correct, i
think. Does anyone know what might be causing the problem?

foreach (MethodInfo method in this.GetType().GetMethods())
methodSequenceNumber = -1;
methodsIsIncomplete = false;

foreach (Attribute attribute in method.GetCustomAttributes(false))
if (attribute is ExecutedInRunAllTestsAttribute)
methodSequenceNumber = (attribute as

methodsIsIncomplete = (attribute is NotCompletedAttribute);
if (methodsIsIncomplete)
These are the Attribute subclasses:
public class NotCompletedAttribute : Attribute
public NotCompletedAttribute()


public class ExecutedInRunAllTestsAttribute : Attribute
private int executionOrder;

public ExecutedInRunAllTestsAttribute(int executionOrder)
this.executionOrder = executionOrder;

public int ExecutionOrder
return executionOrder;
I tried to use some extra AttributeUsage parameters, with the same

Thanks in advance !

Oct 14 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.