获取.NET程序集的AssemblyInformationalVersion价值?价值、程序、NET、AssemblyInformationalVersion

2023-09-03 15:37:47 作者:情有独钟°

什么是获得C#语法大会 AssemblyInformationalVersion 在运行时的属性值?例如:

[总成:AssemblyInformationalVersion(1.2.3.4)]

解决方案

 使用System.Reflection.Assembly
使用System.Diagnostics.FileVersionInfo

// ...

公共字符串GetInformationalVersion(议会大会){
    返回FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion;
}
 

What is the C# syntax for getting the assembly's AssemblyInformationalVersion attribute value at runtime? Example:

.NET中如何获取本程序的程序集信息啊

[assembly: AssemblyInformationalVersion("1.2.3.4")]

解决方案

using System.Reflection.Assembly  
using System.Diagnostics.FileVersionInfo

// ...

public string GetInformationalVersion(Assembly assembly) {
    return FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion;
}