How can I get the assembly file version

In AssemblyInfo there are two assembly versions:

  • 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.
  • I can get the Assembly Version with the following line of code:

    Version version = Assembly.GetEntryAssembly().GetName().Version;
    

    But how can I get the Assembly File 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();
    FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
    string version = fvi.FileVersion;
    

    There are three versions: assembly , file , and product . They are used by different features and take on different default values if you don't explicit specify them.

    string assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); 
    string assemblyVersion = Assembly.LoadFile('your assembly file').GetName().Version.ToString(); 
    string fileVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; 
    string productVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion;
    

    当我想要访问应用程序文件版本(在装配信息 - >文件版本中设置的内容)时,说在表单加载中设置标签的文本以显示版本,我刚刚使用过

    versionlabel.Text = "Version " + Application.ProductVersion;
    
    链接地址: http://www.djcxy.com/p/6430.html

    上一篇: 可编辑的程序集依赖关系图生成

    下一篇: 我如何获得组件文件版本