List all .NET Attributes in the Loaded Assemblies

Here’s how to list all the .NET Attributes in the loaded assemblies.

static void Main(string[] args)

var attributes = from assembly in AppDomain.CurrentDomain.GetAssemblies()
from exptype in assembly.GetExportedTypes()
where typeof(Attribute).IsAssignableFrom(exptype)
select exptype;

foreach (var nm in attributes)
Console.WriteLine("Attribute Name: {0} \nFullName: {1}",
nm.Name, nm.FullName);


Note: The results may vary on your machine. Since we are referring to the GetExportedTypes() which returns type visible outside the assembly, you can get different results by adding new references (Right click project > Add Reference ) or by changing the access modifiers of the types.



Check out Attributes Every .NET Developer Should Know About


Longest and Shortest Type Name in .NET 4.0 using LINQ

Will you give this article a +1 ? Thanks in advance

About The Author

Suprotim Agarwal
Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook

Follow him on twitter @suprotimagarwal

No comments: