Version number display in About screen

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

Hello

I would like to display the Version number of my application in the
About screen. I manually set this value in the Properties of my
deployment project. How can this value be accessed at runtime?

Thanks for any help!
 
If you specify it in the assemblyinfo, you can get to it like this (just one
example, it can get much more complex)
System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly
..GetExecutingAssembly.Location).FileMajorPart.ToString
 
Dave,

I'm not sure about getting it when you set the version in your deployment
project, but this is how I get it if I set it in the <AssemblyVersion>
attribute in the AssemblyInfo file in the project:

-------------------------------
Imports System.Reflection


.......

With [Assembly].GetEntryAssembly.GetName
lblVersion.Text = "Version: " & .Version.ToString(2) & " (Build " &
..Version.Build.ToString & ")"
End With

-------------------------------

The above example gets the version of the *entry* assembly (the main program
that started your code).

HTH,

Trev.
 
I, too, am not sure how to get it if you set it in your deployment project, but if you set it in the AssemblyInfo.vb file (and if you are retrieving the version of the main running application), then there's a much easier way to do it than some other people have informed you. As long as you are getting the version of the assembly that is loaded by default when you open the executable (and not an assembly that is, say, loaded into the AppDomain after the fact, or an assembly being used as a resource), then you can simply use the Application.ProductVersion string object

That's how I usually do it

Ben
 
Back
Top