Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 29th, 2005, 03:10 AM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting the Version number at Runtime

How to get the version number of the assembly at runtime.
Basically ,
I want to compare assemblies at runtime , so i need the version number of the assembly
thanks

regards,
Pallav
Reply With Quote
  #2 (permalink)  
Old September 29th, 2005, 09:01 AM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

The following code works on ASP 1.x but I haven't tested it on 2.0:
Code:
// Bind the version label
Assembly myAssembly;
// Instantiate a target object.
Int32 intToGetType = new Int32();
Type myType;
// Set the Type instance to the target class type.
myType = intToGetType.GetType();
// Instantiate an Assembly class to the assembly housing the Integer type.  
myAssembly = Assembly.GetAssembly(intToGetType.GetType());
// Display the name of the assembly currently executing
string myName = Assembly.GetExecutingAssembly().GetName().Version.ToString();
lblVersion.Text = myName;
The assembly exposes other useful properties as well.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #3 (permalink)  
Old September 29th, 2005, 09:52 AM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

P.s. you need the following using statement for this to work:
Code:
using System.Reflection;
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
existing dll version number arifsharif_2001 Visual Studio 2005 0 May 17th, 2007 02:21 AM
Unable to find a version of the runtime ....... ASPDharm ASP.NET 2.0 Basics 0 January 16th, 2007 07:03 AM
Version of .NET runtime registered on IIS Bob Bedell ASP.NET 1.0 and 1.1 Professional 3 October 17th, 2006 03:13 PM
How to put the version number i'm working on eresina General .NET 2 January 6th, 2005 01:13 PM



All times are GMT -4. The time now is 07:15 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.