Reflection: assembly gets version giving incorrect version value

I use the following code to get the assembly set version in the Windows GAC folder.

FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
                string productVersion = fvi.ProductVersion;

After running the above code, I am mannualy RightClick and get the version of assemblies. The version returned productVersionis different from the manual value for some assemblies . Any possible reason?

+3
source share
1 answer

For the file version of the assembly object, use:

var assembly = System.Reflection.Assembly.GetExecutingAssembly(); // the current assembly

var version = assembly.GetName().Version.ToString();
+4
source

All Articles