Every C# project typically contains a prefab file called AssemblyInfo.cs which contains the lines
// You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.2.*")] [assembly: AssemblyFileVersion("126.96.36.199")]
Though these assembly attributes are named quite similarly, they must be retrieved in different ways.
string fileversion = null; var a = Assembly.GetExecutingAssembly() .GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true) .Cast<AssemblyFileVersionAttribute>() .FirstOrDefault(); if (a != null) fileversion = a.Version;
Compare this to the processing of AssemblyVersion, which can be retrieved from the current assembly using
string assemblyversion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
(I noticed that I wrote about this topic many years ago, but I didn’t remember, and probably you didn’t either 😉 )