Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - how to find out the version of an assembly?

 
Thread Tools Search this Thread
Old 06-05-2004, 04:50 PM   #1
Default how to find out the version of an assembly?


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




Bob
  Reply With Quote
Old 06-05-2004, 05:09 PM   #2
John
 
Posts: n/a
Default Re: how to find out the version of an assembly?
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" <> wrote in message
news:%...
> 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
>
>





John
  Reply With Quote
Old 06-05-2004, 09:45 PM   #3
Bob
 
Posts: n/a
Default Re: how to find out the version of an assembly?
Thanks a lot for the help John. Exacly what I needed. Bob

"John" <> wrote in message
news:wemwc.7257$...
> 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" <> wrote in message
> news:%...
> > 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
> >
> >

>
>





Bob
  Reply With Quote
Old 06-06-2004, 08:02 AM   #4
Nicholas Paldino [.NET/C# MVP]
 
Posts: n/a
Default Re: how to find out the version of an assembly?
John,

Thanks for the quote =)


--
- Nicholas Paldino [.NET/C# MVP]
-

"John" <> wrote in message
news:wemwc.7257$...
> 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" <> wrote in message
> news:%...
> > 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
> >
> >

>
>





Nicholas Paldino [.NET/C# MVP]
  Reply With Quote
Old 06-07-2004, 06:52 AM   #5
Marc Scheuner [MVP ADSI]
 
Posts: n/a
Default Re: how to find out the version of an assembly?
>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


Marc Scheuner [MVP ADSI]
  Reply With Quote
Old 09-20-2006, 07:12 AM   #6
cprogkan
Junior Member
 
Join Date: Sep 2006
Posts: 2
Default this i sfine but what if u can't load the dll ?
if the dll doesn't follow com guidelines how to get the version ,prod version info without loading it using the loadlib function ?

thanks


cprogkan
cprogkan is offline   Reply With Quote
Old 09-20-2006, 07:13 AM   #7
cprogkan
Junior Member
 
Join Date: Sep 2006
Posts: 2
Default this is fine but what if u can't load the dll ?
if the dll doesn't follow com guidelines how to get the version ,prod version info without loading it using the loadlib function ?

thanks


cprogkan
cprogkan is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Insane" "Defined" By Criminal Minds As 'Ability To Perceive Them' {HRI 20040422-V2.1} - (Version 2.1 on 24 June 2005) Leonardo Been DVD Video 1 08-28-2005 11:49 AM
The Nature Of Life As Seen From Earth - Life Energy Particles - Perception At A Distance {HRI 20010829-pi9-V2.0} - (part issue 9 Version 2.0 on 21 Aug 2005) Koos Nolst Trenite DVD Video 1 08-28-2005 10:23 AM
"Napoleon" by Abel Gance - does any version feature the snowball battle in Brienne? un fake di Alberto DVD Video 6 06-24-2005 12:26 PM
New Releases: Six Feet Under S4, Astaire & Rogers, Ice Princess: Updated complete downloadable R1 DVD DB & info lists Doug MacLean DVD Video 0 05-10-2005 06:55 AM
Original version "Exorcist" DVD OOP? bosco335 DVD Video 4 05-02-2005 12:51 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46