473,507 Members | 2,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to reference Assembly attributes

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
1 1758
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
285
by: julien | last post by:
Hello, I got the error "Object reference not set to an instance of an object" in this piece of code: Assembly asm = Assembly.LoadFrom(location); System.Attribute attributes =...
4
1522
by: Edward Diener | last post by:
I have a class Y in assembly B which is derived from a class Z in assembly C. So I correctly add a reference to assembly C in assembly B, build assembly B and everything builds fine. Now I create...
0
1226
by: Kathy Burke | last post by:
I'm providing the following syntax in hopes someone could tell me why I get an object reference error on the second one. The first one works, using an xmlDocument, the second one immediately...
10
3416
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
2
2564
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
5
2448
by: serge calderara | last post by:
Dear all, I do not see the difference between Referencing an assembliy for use in my project and Register it on a page ? At the end if I want to use assembly functionnality , I need anyway to...
1
283
by: AlexB | last post by:
A windows forms .NET application has various built in attributes like: <Assembly: AssemblyTitle("MyAssembly")> <Assembly: AssemblyDescription("Blahblah")> <Assembly: AssemblyCompany("XYZ")> ...
8
3876
by: tshad | last post by:
In VS 2003, I am trying to set the onload property of the body tag to "". I do this all the time from my Dreamweaver pages (one page aspx page). But in a code-behind page I need to set a...
2
11758
by: Paul | last post by:
Hi, I have experience in Java and C++ but I am rather new to C# and just started learning it. I am using Visual C# 2005 Express Edition and I found that there is a file called "AssemblyInfo.cs",...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7110
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.