Hi,
Extracting attributes of an assembly is very easy using .NET.
Following program will show this.
private void RetrieveAssemblyInfo()
{
Assembly asm = Assembly.GetExecutingAssembly ();
if ( asm == null )
return;
object[] asmAttributes = asm.GetCustomAttributes(false );
if ( asmAttributes.Length == 0 )
return;
foreach ( Attribute attribute in asmAttributes )
{
if ( attribute.GetType () == typeof ( AssemblyTitleAttribute ) )
{
tbxAssemblyTitle.Text = ( ( AssemblyTitleAttribute ) attribute ).Title;
}
else if ( attribute.GetType () == typeof ( AssemblyCompanyAttribute ) )
{
tbxCompanyName.Text = ( ( AssemblyCompanyAttribute ) attribute ).Company;
}
else if ( attribute.GetType () == typeof ( AssemblyCopyrightAttribute ) )
{
tbxCopyrights.Text = ( ( AssemblyCopyrightAttribute ) attribute ).Copyright;
}
else if ( attribute.GetType () == typeof ( AssemblyFileVersionAttribute ) )
{
tbxVersion.Text = ( ( AssemblyFileVersionAttribute ) attribute ).Version;
}
}
}
private void button1_Click( object sender, EventArgs e )
{
RetrieveAssemblyInfo ();
}
No comments:
Post a Comment