473,379 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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 1746
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
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
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
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
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
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
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
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
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
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",...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.