It should come as no surprise that the following code doesn't do what I expected:
object[] attribs = Assembly.GetExecutingAssembly().GetType().GetCustomAttributes(typeof(Attribute), false);
Instead I just needed to remove the call to GetType():
object[] attribs = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(Attribute), false);
The Assembly class provides a handy GetCustomAttributes() method since calling it on the Assembly type itself doesn't really help you much. The first example gets you a bunch of crazy attributes that really aren't what I was looking for; the second returns all of the assembly-decorating attributes declared in my AssemblyInfo.cs.
No comments:
Post a Comment