How do I retreive the value of AssemblyTitleAttribute

  • Thread starter Thread starter Roy Chastain
  • Start date Start date
R

Roy Chastain

I would like to be able to retrieve the values of several of the
AssemblyXXXAttribute classes. How do I get to them at runtime?

Thanks
 
Roy,
I would like to be able to retrieve the values of several of the
AssemblyXXXAttribute classes. How do I get to them at runtime?

Many of them you get with Assembly.GetCustomAttributes. For example

Assembly thisAsm = this.GetType().Assembly;
object[] attrs = thisAsm.GetCustomAttributes(
typeof(AssemblyTitleAttribute), false ) );
if ( attrs.Length == 1 )
Console.WriteLine( ((AssemblyTitleAttribute)attrs[0]).Title );

But AssemblyVersionAttribute becomes part of the assembly name, which
you retrieve with Assembly.GetName instead.

Console.WriteLine( thisAsm.GetName().Version );



Mattias
 
Back
Top