我需要显示AssemblyVersion和AssemblyFileVersion。在AssemblyInfo.cs中,我有: [assembly:AssemblyVersion(“1.0。*”)] [assembly:AssemblyFileVersion(“2009.8.0”)]
然而,当我参考上述内容时,我只得到“2009.8.0”: 公共类VersionInfo { public static string AppVersion() { return System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly()。Location).FileMajorPart +“。” + System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly()。Location).FileMinorPart +“。” + System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly()。Location).FileBuildPart; } }
如何显示两个值? 感谢。
答案 0 :(得分:2)
Application.ProductVersion版本将返回AssemblyFileVersion
public string AppVersion()
{
return Application.ProductVersion + "." +
Assembly.GetExecutingAssembly().GetName().Version.ToString();
}