Application.ProductVersion
is not showing the incremental version. can anybody help me how to perform this, using C# ?
Asked
Active
Viewed 8,110 times
0

Asad Iqbal
- 304
- 4
- 16
3 Answers
4
You can have build and revision incremented for you but not major and minor.
Simply substitute
[assembly: AssemblyVersion("1.0.0.0")]
with
[assembly: AssemblyVersion("1.0.*")]
in the AssemblyInfo.cs

Rune FS
- 21,497
- 7
- 62
- 96
-
yes i add up the initial values in assembly that is 1.0.0.0 but it is not increment in each build. i am showing the Version detail in my app "About Tab" via using code like this label.Text = Application.ProductName + " Version " + Application.ProductVersion – Asad Iqbal Sep 26 '11 at 12:27
-
@Asad the value should not be 1.0.0.0 but 1.0.* if you wish the build/revision part to be incremented automatically. – Rune FS Sep 26 '11 at 12:28
3
Have you tried grabbing the Assembly's version?
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
Perhaps this is what you are looking for.
Also check out this other SO post - I think this is what you are looking for.
Automatically update version number
Below is a second link to a .Net add-in that automatically increments the:
- Major
- Minor
- Build
- Revision

Community
- 1
- 1
-
yes i add up the initial values in assembly that is 1.0.0.0 but it is not increment in each build. i am showing the Version detail in my app "About Tab" via using code like this label.Text = Application.ProductName + " Version " + Application.ProductVersion – Asad Iqbal Sep 26 '11 at 12:26
-
1
I have found that it works well to simply display the date of the last build using the following wherever a product version is needed:
System.IO.File.GetLastWriteTime(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString("yyyy.MM.dd.HHMM")
Rather than attempting to get the version from something like the following:
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
object[] attributes = assembly.GetCustomAttributes(typeof(System.Reflection.AssemblyFileVersionAttribute), false);
object attribute = null;
if (attributes.Length > 0)
{
attribute = attributes[0] as System.Reflection.AssemblyFileVersionAttribute;
}

user8128167
- 6,929
- 6
- 66
- 79