Sunday, 18 August 2013

Get application version always return 1.0.0.0

Get application version always return 1.0.0.0

I want to show the application version in my application. I did some
research and I tried this:
System.Reflection.Assembly assembly =
System.Reflection.Assembly.GetExecutingAssembly();
Version version = assembly.GetName().Version;
_applicationVersion = version.Major + "." + version.Minor + "." +
version.Build;
But my version variable always shows 1.0.0.0
When I publish my application and I install it on my computer it shows in
my program list that it's version 1.0.1.1. Which is the number I expect my
application to show
Does anybody has a solution for this?
EDIT
My problem was that I was just setting the publish version in the
properties of my visual studio project. Which doesn't seem to be the
application version you get from the code I posted above. I've found the
AssemblyInfo.cs file which also has 2 attributes:
[assembly: AssemblyVersion("x.x.x.x")]
[assembly: AssemblyFileVersion("x.x.x.x")]
So that solved my first problem.
But what is the difference between those 2 version numbers, why do you
want to have 2 different versions? And what does the publish version stand
for?

No comments:

Post a Comment