By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,915 Members | 1,349 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,915 IT Pros & Developers. It's quick & easy.

How to reference Assembly attributes

P: n/a
A windows forms .NET application has various built in
attributes like:

<Assembly: AssemblyTitle("MyAssembly")>
<Assembly: AssemblyDescription("Blahblah")>
<Assembly: AssemblyCompany("XYZ")>

But how can I reference these from within my windows forms
application???
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

Thanks for your post.

1. We can call the method GetCustomAttributes() under
System.Reflection.Assembly to get the custom attributes for the assembly.
System.Reflection namespace contains a list of assembly attribute classes
that you are interested say, AssemblyTitleAttribute,
AssemblyDescriptionAttribute, AssemblyCompanyAttribute, etc. Please refer
to the following MSDN documentation:

Assembly.GetCustomAttributes
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemreflectionassemblyclassgetcustomattribu testopic.asp?frame=true

System.Reflection Namespace
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemreflection.asp?frame=true

2. Calling GetCustomAttributes(true) will return an object array of all the
attributes. We are able to loop through the array to get each attribute.
The following code snippet call GetCustomAttributes(type, true) which
returns AssemblyTitleAttribute specifically.

//--------------code snippet-------------------
using System.Reflection;
...
AssemblyTitleAttribute assemlyTitle;// = new AssemblyTitleAttribute("");
object [] objAttributes =
Assembly.GetExecutingAssembly().GetCustomAttribute s(typeof(AssemblyTitleAttr
ibute),true);
assemlyTitle = (AssemblyTitleAttribute)objAttributes[0];
MessageBox.Show (assemlyTitle.Title);
//-------------------end of-----------------------

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.