Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
|
.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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 29th, 2005, 03:10 AM
Registered User
 
Join Date: Aug 2005
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
 
Old September 29th, 2005, 09:01 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.
 
Old September 29th, 2005, 09:52 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.