Get application version always return 1.0.0.0

徘徊边缘 提交于 2019-12-23 14:45:49

问题


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?

Isn't there always just 1 version number for an application?

来源:https://stackoverflow.com/questions/18300163/get-application-version-always-return-1-0-0-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!