C# VSTO 如何获取properties发布时的发布版本号?而非application的版本。
最近在做Word 2016的VSTO开发,特别想获得双击Properties后,其中的发布版本号。如下图所示。
#region 尝试网上各位大拿介绍的各种获取程序发布版本号
String PropertiesOpt2 = "";
PropertiesOpt2 = "程序集版本:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "\n";
PropertiesOpt2 += "文件版本:" + Application.ProductVersion.ToString() + "\n";
PropertiesOpt2 += "Globals:" + Assembly.GetExecutingAssembly().ImageRuntimeVersion.ToString();
#endregion
#region [尝试网上大拿提供的]可惜只能获取启动的word版本
var serverFileVersion = "";
try
{
string loadexeName = System.Windows.Forms.Application.ExecutablePath;
//loadexeName : ""C:\\Program Files\\Microsoft Office\\root\\Office16\\WINWORD.EXE""
System.Diagnostics.FileVersionInfo fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(loadexeName);
serverFileVersion = string.Format("{0}.{1}.{2}.{3}", fileVersionInfo.FileMajorPart, fileVersionInfo.FileMinorPart, fileVersionInfo.FileBuildPart, fileVersionInfo.FilePrivatePart);
}
catch (Exception)
{
throw;
}
#endregion
期望在程序运行过程中,准确获得该VSTO程序的发布版本号。但是,并非application之类的。