FileVersionInfo.GetVersionInfo (asm.Location) does not work for built-in assemblies (for example, using Fody Costura to send a single EXE instead of an executable file and all its dependent assemblies). In this case, the following works as a reserve:
var assembly = Assembly.GetExecutingAssembly(); var fileVersionAttribute = assembly.CustomAttributes.FirstOrDefault(ca => ca.AttributeType == typeof(AssemblyFileVersionAttribute)); if (fileVersionAttribute != null && fileVersionAttribute.ConstructorArguments.Any()) return fileVersionAttribute.ConstructorArguments[0].ToString().Replace("\"",""); return string.Empty;
source share