473,386 Members | 1,827 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,386 software developers and data experts.

Assembly Information

Hello,

I want to create a very simple control which displays the assembly name
and version of the DLL where the control is inserted.

Could somebody tell me how can I access the name and version from my
control class?

Thanks,

Miguel

Oct 20 '06 #1
1 976
Hi,

shapper wrote:
Hello,

I want to create a very simple control which displays the assembly name
and version of the DLL where the control is inserted.

Could somebody tell me how can I access the name and version from my
control class?

Thanks,

Miguel
Using Assembly and FileVersionInfo, you can get information about the
assembly attributes:

// First get the Assembly
Type tyType = typeof( MyControl );
Assembly oAssembly = tyType.Assembly;

FileVersionInfo oFileVersionInfo
= FileVersionInfo.GetVersionInfo( oAssembly.Location );

// Name entered in the "Product Name" attribute
string strName = oFileVersionInfo.ProductName;

// Assembly description
string strDescription = oFileVersionInfo.Comments;

// Copyright and Trademark
string strCopyright = oFileVersionInfo.LegalCopyright;
string strTrademark = oFileVersionInfo.LegalTrademarks;

// Company name
string strCompanyName = oFileVersionInfo.CompanyName;

Versions are tricky, because you must distinguish between File Version
and Product Version.

The File Version is the attribute set with
[assembly: AssemblyVersion("1.7.1.*")]

Usually, you want the File Version. You can build the version by using

oFileVersionInfo.FileMajorPart
oFileVersionInfo.FileMinorPart
oFileVersionInfo.FileBuildPart
oFileVersionInfo.FilePrivatePart

The Product Version is set with
[assembly: AssemblyInformationalVersion("1.7.1.12")]

You can get it with
string strProductVersion = oFileVersionInfo.ProductVersion;

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Oct 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Carlos G Benevides | last post by:
I have a ASP.Net web application that has two assemblies that run under com+. Under Windows 2000 the two assemblies are added to com+ automatically when instantiated from the web site. For this...
3
by: Atul Godbole | last post by:
Suppose an assembly "Main" is using class "A" from another Assembly "Dep" as follows : A a = new A(); a.MethodOne(); At what time is the call to MethodOne linked to the actual MSIL (method...
1
by: Brian | last post by:
I've looked through the previous posts on this one and have verified permissions and location of my Dlls, but I am still getting an exception when I try to Load an assembly. The directory where...
3
by: Karl Hungus | last post by:
A cs file I compiled into an assembly dll is in my bin directory. In the cs file I have a using statement for System.Xml I compiled it using this command: csc /out:XmlContent.dll /t:library...
3
by: Web Team | last post by:
Hi All, I recently moved our assembly which stores our 'common' code into the GAC. I then moved all copies of this assembly out of the /bin folders, restarted IIS. I get the error below. This...
7
by: R Reyes | last post by:
Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? I'm trying to manipulate MS Word from my Web Form application and I can't get passed...
3
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
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",...
0
by: =?Utf-8?B?Q29saXZpZXI=?= | last post by:
If anyone can help me with this I would really appreciate it: I have an assembly into which I have linked a manifest file as a Win32 resource. This is necessary since I want to use a class in this...
10
by: =?Utf-8?B?SmFtZXMgV29uZw==?= | last post by:
Hi everybody, I'm trying to use the new VB 2008 right now and I want to know how to preset the company name and copyright informtion in Assembly Information. In my current VB 2005, company name...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.