Friday, May 27, 2005

Reading attributes of an assembly in .NET

In System.Reflection namespace are assembly attribute classes. Here is a sample for one of those. You can try the same with the other attributes you want to read.

Assembly executingAssembly=Assembly.GetExecutingAssembly();
AssemblyCopyrightAttribute copyright=AssemblyCopyrightAttribute.GetCustomAttribute(executingAssembly,typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute; System.Console.WriteLine(copyright.Copyright);

Custom attributes defined on the assembly can be read using the same way.