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
?
The version number is stored in the assembly manifest along with other identity information, including the assembly name and public key, as well as information on relationships and identities of other assemblies connected with the application.
It's the version number given to file as in file system. It's displayed by Windows Explorer, and never used by . NET framework or runtime for referencing.
The Product version of the assembly. This is the version you would use when talking to customers or for display on your website. This version can be a string, like '1.0 Release Candidate'. The AssemblyInformationalVersion is optional. If not given, the AssemblyFileVersion is used.
The AssemblyVersion attribute assigns the version number of the assembly, and this is embedded in the manifest. Version information for an assembly consists of the following four values : a major and minor version number, and two further optional build and revision numbers.
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;
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With