Get Custom Attributes : Attributes « Reflection « C# / CSharp Tutorial






using System;
using System.Reflection;

class Program {
    static void Main(string[] args) {
        string assemblyName = "Your";

        try {
            Assembly a = Assembly.LoadFrom(assemblyName);
            object[] attributes = a.GetCustomAttributes(true);
            if (attributes.Length > 0) {
                Console.WriteLine("Assembly attributes for '{0}'...", assemblyName);

                foreach (object o in attributes)
                    Console.WriteLine("  {0}", o.ToString());
            } else
                Console.WriteLine("Assembly {0} contains no Attributes.", assemblyName);
        } catch (Exception ex) {
            Console.WriteLine(ex.ToString());
        }
    }
}








19.2.Attributes
19.2.1.Get Custom Attributes
19.2.2.Using Reflection to get Custom Attributes
19.2.3.Reflect Attribute
19.2.4.Get Assembly Description Attribute