Find Attribytes from assembly name : Assembly : Reflection C# Source Code


Custom Search

C# Source Code » Reflection » Assembly »

 

Find Attribytes from assembly name









    


using System;
using System.Reflection;

public class FindAttributes {
  static void Main(string[] args) {
      String assemblyName = "test.exe" ;
      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 ( ) ) ;
      }
  }

}
           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Reflection
» Assembly