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

how to find out the version of an assembly?

Bob
I need to extract the version number of an assembly in my .NET Windows app.
The assembly is not referenced by this Windows app. I think I need to use
reflection but just can't figure out the coding. Could someone help?

Thanks a lot in advance
Bob
Nov 18 '05 #1
4 996
Quoting from some answers from other people in these forums:

The GetName method on the Assembly will give you an instance of the
AssemblyName class. That will have a Version property which will return an
Version class instance. Once you have this, you should be able to use the
properties of the class (Build, Major, Minor, Revision) or you can get a
string representation by calling ToString.

(orig post by Nicholas Paldino [.NET/C# MVP] )

And:

************
Code Sample
************
try
{
Assembly a = Assembly.LoadFrom("FTPClient.dll");
Console.WriteLine("Image Runtime Version: {0}", a.FullName);
Debug.WriteLine("Image Runtime Version: " + a.FullName);
}
catch (Exception e)
{
Console.WriteLine("Exception occurred: {0}", e.Message);
}
finally
{
Console.ReadLine();
}

************
Output
************
Image Runtime Version: FTPClient, Version=1.0.1117.28417, Culture=neutral,
PublicKeyToken=null

(orig post by Mike Diehl)

Hope that gives you something to work with. Anyway, good luck!
" Bob" <bo*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I need to extract the version number of an assembly in my .NET Windows app. The assembly is not referenced by this Windows app. I think I need to use
reflection but just can't figure out the coding. Could someone help?

Thanks a lot in advance
Bob

Nov 18 '05 #2
Bob
Thanks a lot for the help John. Exacly what I needed. Bob

"John" <jc*****************@hotmail.com> wrote in message
news:we*****************@news-server.bigpond.net.au...
Quoting from some answers from other people in these forums:

The GetName method on the Assembly will give you an instance of the
AssemblyName class. That will have a Version property which will return an Version class instance. Once you have this, you should be able to use the
properties of the class (Build, Major, Minor, Revision) or you can get a
string representation by calling ToString.

(orig post by Nicholas Paldino [.NET/C# MVP] )

And:

************
Code Sample
************
try
{
Assembly a = Assembly.LoadFrom("FTPClient.dll");
Console.WriteLine("Image Runtime Version: {0}", a.FullName);
Debug.WriteLine("Image Runtime Version: " + a.FullName);
}
catch (Exception e)
{
Console.WriteLine("Exception occurred: {0}", e.Message);
}
finally
{
Console.ReadLine();
}

************
Output
************
Image Runtime Version: FTPClient, Version=1.0.1117.28417, Culture=neutral,
PublicKeyToken=null

(orig post by Mike Diehl)

Hope that gives you something to work with. Anyway, good luck!
" Bob" <bo*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I need to extract the version number of an assembly in my .NET Windows

app.
The assembly is not referenced by this Windows app. I think I need to use reflection but just can't figure out the coding. Could someone help?

Thanks a lot in advance
Bob


Nov 18 '05 #3
John,

Thanks for the quote =)
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John" <jc*****************@hotmail.com> wrote in message
news:we*****************@news-server.bigpond.net.au...
Quoting from some answers from other people in these forums:

The GetName method on the Assembly will give you an instance of the
AssemblyName class. That will have a Version property which will return an Version class instance. Once you have this, you should be able to use the
properties of the class (Build, Major, Minor, Revision) or you can get a
string representation by calling ToString.

(orig post by Nicholas Paldino [.NET/C# MVP] )

And:

************
Code Sample
************
try
{
Assembly a = Assembly.LoadFrom("FTPClient.dll");
Console.WriteLine("Image Runtime Version: {0}", a.FullName);
Debug.WriteLine("Image Runtime Version: " + a.FullName);
}
catch (Exception e)
{
Console.WriteLine("Exception occurred: {0}", e.Message);
}
finally
{
Console.ReadLine();
}

************
Output
************
Image Runtime Version: FTPClient, Version=1.0.1117.28417, Culture=neutral,
PublicKeyToken=null

(orig post by Mike Diehl)

Hope that gives you something to work with. Anyway, good luck!
" Bob" <bo*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I need to extract the version number of an assembly in my .NET Windows

app.
The assembly is not referenced by this Windows app. I think I need to use reflection but just can't figure out the coding. Could someone help?

Thanks a lot in advance
Bob


Nov 18 '05 #4
>Quoting from some answers from other people in these forums:
The GetName method on the Assembly will give you an instance of the
AssemblyName class. That will have a Version property which will return an
Version class instance.


If you know the name and location of the assembly, you can also use
the FileVersionInfo class. The benefit is the fact you don't have to
actually LOAD the assembly to get at its file and product version info
(this is especially important since you can't UNLOAD an assembly per
se).

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Nov 18 '05 #5

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

Similar topics

2
by: Terence Shek | last post by:
Is there a way to set the application binding policy so that it always binds to the latest version of an assembly? I'm hoping there is a way to avoid updating the application's binding...
4
by: Bob | last post by:
I need to extract the version number of an assembly in my .NET Windows app. The assembly is not referenced by this Windows app. I think I need to use reflection but just can't figure out the...
4
by: Bob | last post by:
Could anyone suggest me some examples/articles on creating a setup program in VS.NET that can install the assembly into the GAC? I have done some search and research myself and have some basic...
0
by: Don | last post by:
I intermittently get a runtime Compilation Error that says 'The compiler failed with error code 2000'. It appears that a DLL cannot be found in the 'temporary asp.net files' directory. The...
0
by: Michael R. Pierotti | last post by:
Has anyone seen this error before when trying to make the install on a program. ------ Starting pre-build validation for project 'HafaSMPPInstall' ------ WARNING: Unable to find dependency...
3
by: DJTN | last post by:
I'm getting the following error when I try to compile my setup project in VS 2002. I have re-installed the .net framework 1.1 and it didnt solve the problem. WARNING: Unable to find dependency...
1
by: realgeek | last post by:
Hi. I am writing a class lib that has com interop enabled and it is housed and used within some other application. So then, I serialize one of the classes, and on subsequent launches I try to...
1
by: amir | last post by:
Hi, When compiling a page in VS2005 this morning I received 101 messages regarding schema problems in my web.config file. When I go to view an aspx page in my IIS, IE just displays a blank...
1
by: OrionLee | last post by:
I am using C# to work with a 3rd party DLL (Nevron Charts), and attempting to serialise it. The serialisation itself is handled somewhere inside the DLL, so to get it to happen you call the Nevron's...
1
by: blondsecret | last post by:
Hello everyone, after installing a Strokes 'easylearning' CD-Rom, following dialogue is shown to me: Microsoft .NET Framework An unhandled exception has occurred in a component in your...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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,...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.