At runtime find the application's build version?
-
Is it possible to pull from somewhere after the application has been compiled to know what it's build version number is so I can show it in a label? I am thinking I can pull if from the assembly but my attempts have failed. Please can someone point me in the right direction? Here is what I am currently doing and it does not match the build version of the application that I am compiling. lblAppVersion.Text = "Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " or " + System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString();
-
Is it possible to pull from somewhere after the application has been compiled to know what it's build version number is so I can show it in a label? I am thinking I can pull if from the assembly but my attempts have failed. Please can someone point me in the right direction? Here is what I am currently doing and it does not match the build version of the application that I am compiling. lblAppVersion.Text = "Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " or " + System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString();
-
Are you looking for something like this?
labelControlVersion.Text = string.Format ( "Version: {0}", Assembly.GetExecutingAssembly ( ).GetName ( ).Version ) ;
Not quite I want the applications build version... which would show on the project properties screen under the publish tab. any idea where this is?
-
Is it possible to pull from somewhere after the application has been compiled to know what it's build version number is so I can show it in a label? I am thinking I can pull if from the assembly but my attempts have failed. Please can someone point me in the right direction? Here is what I am currently doing and it does not match the build version of the application that I am compiling. lblAppVersion.Text = "Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " or " + System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString();
What do you want the text in the label to look like? To Get This "Ver. 5.1.2 Rev. 3" Try like this; Dim avi As System.Version = System.Reflection.Assembly.GetExecutingAssembly.GetName.Version lblVersion.Text = "Ver. " & Format(avi.Major, "###0").TrimEnd & "." _ & Format(avi.Minor, "###0").TrimEnd & "." & Format(avi.Build, "###0").TrimEnd _ & " Rev. " & Format(avi.Revision, "###0") Of course this is not the publish version (just saw last post)
-
Is it possible to pull from somewhere after the application has been compiled to know what it's build version number is so I can show it in a label? I am thinking I can pull if from the assembly but my attempts have failed. Please can someone point me in the right direction? Here is what I am currently doing and it does not match the build version of the application that I am compiling. lblAppVersion.Text = "Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " or " + System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString();
it is very easy tog et this info This is a code for this
//get the version from the assemblyinfo.cs
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
//add to label
lblVersion.Text = v.ToString();This information is stored in the AssemblyInfo.cs under Node 'Properties' in Solution explorer! :) Reg, Deep Happy Coding!
-
it is very easy tog et this info This is a code for this
//get the version from the assemblyinfo.cs
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
//add to label
lblVersion.Text = v.ToString();This information is stored in the AssemblyInfo.cs under Node 'Properties' in Solution explorer! :) Reg, Deep Happy Coding!
Thanks I learned that c# does not auto increment the version per each build. That was the issue I was having.