Sean,

Thank you, your code worked nicely. It just seemed to me that something like
this:

                        Assembly asm = typeof(MyClass).Assembly;
                        AssemblyTitleAttribute ata = Attribute.GetCustomAttribute(asm,
AssemblyTitleAttribute);
                        string title = ata.Title;

...should have also worked. Of course, the code above doesn't compile
because GetCustomAttribute wants something else instead of
AssemblyTitleAttribute as the second param.

The docs say it is:

attributeType
The Type object to which the custom attributes are applied.

But I can't quite yet figure out what it should be. Or am I barking up the
wrong tree altogether?

Thanks.

== Ross ==

-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]]On Behalf Of
Sean Greer (SBI-Chico)
Sent: Wednesday, April 17, 2002 10:10 AM
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] newbie question: How to read AssemblyTitle
assembly attribute


This work for me:

Assembly asm = Assembly.GetExecutingAssembly();
object[] atts = asm.GetCustomAttributes(false);

//find the AssemblyTitleAttribute
for(int n = 0; n < atts.Length; n++)
{
        if(atts[n] is AssemblyTitleAttribute)
        {
                AssemblyTitleAttribute ata = (AssemblyTitleAttribute)
atts[n];
                Console.WriteLine(ata.Title);
                break;
        }
}

//Seang

-----Original Message-----
From: Ross Lambert [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 17, 2002 9:36 AM
To: [EMAIL PROTECTED]
Subject: [DOTNET] newbie question: How to read AssemblyTitle assembly
attribute


DotNetters,

I'm bumfuzzled... I can read a custom class attribute but can't seem to do
the same for the assembly that contains it.

Anybody got that off the top of their 'ead? The attribute I'm looking for in
particular is the AssemblyTitle.

Thanks.

== Ross ==

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to