[assembly: Assembly@R_177_4045@ionalVersion("7.1.0.0 Private (Debug build)")]
当我对另一个项目中的可执行文件使用FiLeversionInfo.GetVersionInfo .NET API时,我发现这些值已报告:
>产品版本:7.1.0.0 Private(Debug build)
> ProductMajorPart:7
> ProductMinorPart:1
当我在使用VS2015构建的C#项目中使用相同的属性和字符串值时,ProductMajorPart和ProductMinorPart属性报告为零!
有谁知道行为改变是否是故意的?
我检查了可执行文件中找到的二进制文件版本信息,虽然版本信息中的字符串值与两个文件中的预期值一样,但VS2015可执行文件在VS_FIXEDFILEINFO.dwProductVersionMS和VS_FIXEDFILEINFO.dwProductVersionLS字段中的值为零.
解决方法
对于背景,docs for AssemblyInformationalVersion确实指定:
The attribute defined by this class attaches additional version @R_177_4045@ion to an assembly. If this attribute is applied to an assembly,the string it specifies can be obtained at run time by using the Application.ProductVersion property.
[…] Although you can specify any text,a warning message appears on compilation if the string is not in the format used by the assembly version number […]
从上面:
>除了可以检索字符串本身之外,没有正式的保证;
>警告不要使用自由格式字符串.
您可能,甚至应该在VS connect上提交错误报告,尽管我的感觉是MS将Assembly@R_177_4045@ionalVersion中的自由格式字符串视为不受支持的“意外”功能,并且可能不会将未记录的行为更改视为“错误” .
没有直接相关,但是这个VS 2010错误报告Localized build with free form AssemblyInformationalVersion causes ALINK warning AL1053已被MS关闭,因为无法修复.
在Why is warning CS1607 “The version specified for the ‘product version’ is not in the normal ‘major.minor.build.revision’ format” generated?接受的答案基本上建议一旦你偏离标准的major.minor.build.revision格式,你几乎就是你自己.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。