Assembly version “.001” becomes “.1”

拈花ヽ惹草 提交于 2019-12-23 09:34:42

问题


In WinForms I have an AssemblVersion

[assembly: AssemblyVersion("01.01.01.002")]

However when the splash screen comes up it completely ignores the zeros showing:

1.1.1.2 

as the version which is very inconvenient since later I will actually want to have an assembly version

 [assembly: AssemblyVersion("01.01.01.200")]

Is there a way to avoid this or do I Have to add some number at the beginning of last part of the version like so:

[assembly: AssemblyVersion("01.01.01.102")]

回答1:


The AssemblyVersion attribute stores it's information as a Version object. The components of the Version struct are integers, and are treated as such. So 1.2.3.4 == 1.02.003.004 but 1.2.3.4 != 1.2.3.400

You can use the AssemblyInformationalVersionAttribute to provide aditional, arbitrarily formatted information about your product, as it's information is stored as a string, rather than a Version. So you can do:

[assembly: AssemblyVersion("1.1.1.102")]
[assembly: AssemblyInformationalVersion("v.01 alpha")]

Or whatever you like



来源:https://stackoverflow.com/questions/15694568/assembly-version-001-becomes-1

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