I am reading version information of my wpf application, but I am not getting the correct version as I have write in AssemblyInfo.cs
file. In my file there is
我正在阅读我的wpf应用程序的版本信息,但是我没有得到正确的版本,因为我已经在程序集信息中编写了。cs文件。在我的档案里有
[assembly: AssemblyVersion("0.1.001")]
[assembly: AssemblyFileVersion("0.0.001")]
I am reading version information using this code
我正在使用这段代码阅读版本信息
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
I am getting this version 0.1.1.0
and it should be 0.1.001
我得到的版本是0。1.1.0,应该是0。1.001
Thanks
谢谢
2 个解决方案
#1
23
The properties Major
, Minor
, Build
and Revision
of class Version
are of type int
, not string
. So when string from assembly version is parsed into Version
class, the parts of this string will be converted to int representation. Also there are rule that first number of specified version string is Major
component of Version
:
类版本的主要、次要、构建和修订属性是int类型,而不是string。因此,当将汇编版本中的字符串解析为version类时,该字符串的部分将被转换为int表示形式。也有规则规定,第一个指定版本字符串的数量是版本的主要组成部分:
"1" - 1.0.0.0
"1.2" - 1.2.0.0
"1.2.3" - 1.2.3.0
"1.2.3.4" 1.2.3.4
#2
2
In the MSDN article, it says that:
在MSDN的文章中,它说:
All components of the version must be integers greater than or equal to 0
版本的所有组件必须是大于或等于0的整数
So it's either rounding up or removing trailing zeros to get a valid integer.
所以它要么四舍五入,要么去掉后面的0以得到一个有效的整数。
#1
23
The properties Major
, Minor
, Build
and Revision
of class Version
are of type int
, not string
. So when string from assembly version is parsed into Version
class, the parts of this string will be converted to int representation. Also there are rule that first number of specified version string is Major
component of Version
:
类版本的主要、次要、构建和修订属性是int类型,而不是string。因此,当将汇编版本中的字符串解析为version类时,该字符串的部分将被转换为int表示形式。也有规则规定,第一个指定版本字符串的数量是版本的主要组成部分:
"1" - 1.0.0.0
"1.2" - 1.2.0.0
"1.2.3" - 1.2.3.0
"1.2.3.4" 1.2.3.4
#2
2
In the MSDN article, it says that:
在MSDN的文章中,它说:
All components of the version must be integers greater than or equal to 0
版本的所有组件必须是大于或等于0的整数
So it's either rounding up or removing trailing zeros to get a valid integer.
所以它要么四舍五入,要么去掉后面的0以得到一个有效的整数。