Friday 1 December 2017

c# - How can I get the assembly file version

itemprop="text">


In
AssemblyInfo there are two assembly
versions:




  1. AssemblyVersion:
    Specify the version of the assembly being
    attributed.

  2. 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?



Answer




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;



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...