User Tools

Site Tools

blog:2023-06-19_c_get_assembly_version_to_form_title



2023-06-19 C#: Get assembly version to form title

  • 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.
  • We want to show the version in the Form Title as follows:

Code

  • System.Reflection.Assembly _assembly = 
        System.Reflection.Assembly.GetExecutingAssembly();
    System.Diagnostics.FileVersionInfo _fvi = 
        System.Diagnostics.FileVersionInfo.GetVersionInfo(_assembly.Location);
    string _fileVersion = 
        FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
    string _productVersion = 
        FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion;
    string _version = _fvi.FileVersion;
    this.Text = "PROGRAM V" + _version;

TAGS

  • 64 person(s) visited this page until now.

Permalink blog/2023-06-19_c_get_assembly_version_to_form_title.txt · Last modified: 2023/06/19 10:20 by jethro

oeffentlich