![]() |
|
|
|||||||
![]() |
ASP Net - how to find out the version of an assembly? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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 |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
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] |
|
|
|
#5 |
|
Posts: n/a
|
>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] |
|
|
|
#6 |
|
Junior Member
Join Date: Sep 2006
Posts: 2
|
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 |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Sep 2006
Posts: 2
|
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 |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |