Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I retreive the value of AssemblyTitleAttribute

1 view
Skip to first unread message

Roy Chastain

unread,
Mar 1, 2004, 7:46:47 AM3/1/04
to
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 Chastain
KMSystems, Inc.

Mattias Sjögren

unread,
Mar 1, 2004, 10:49:43 AM3/1/04
to
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

0 new messages