如何获取程序集文件版本 [英] How can I get the assembly file version
本文介绍了如何获取程序集文件版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在AssemblyInfo
中有两个程序集版本:
In AssemblyInfo
there are two assembly versions:
AssemblyVersion
:指定要归因的程序集的版本.AssemblyFileVersion
:指示编译器使用 Win32 文件版本资源的特定版本号.Win32 文件版本不需要与程序集的版本号相同.
AssemblyVersion
: Specify the version of the assembly being attributed.AssemblyFileVersion
: Instructs a compiler to use a specific version number for the Win32 file version resource. The Win32 file version is not required to be the same as the assembly's version number.
我可以使用以下代码行获取Assembly Version
:
I can get the Assembly Version
with the following line of code:
Version version = Assembly.GetEntryAssembly().GetName().Version;
但是我怎样才能获得程序集文件版本
?
推荐答案
请参阅我上面的评论,以了解您真正想要什么.希望是这样:
See my comment above asking for clarification on what you really want. Hopefully this is it:
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
string version = fvi.FileVersion;
这篇关于如何获取程序集文件版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文