如何以编程方式获取C#中的当前产品版本?
我的代码:
VersionNumber = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
我正在获取VersionNumber=1.0.0.0,但当前版本是1.0.0.12。
发布于 2011-06-28 05:45:39
我得到了我的问题的答案,它只是提供了对System.Deployment.Application的引用,虽然它不能在visual studio的开发中工作,但一旦部署了应用程序,它就会工作。
//using System.Deployment.Application;
//using System.Reflection;
public string CurrentVersion
{
get
{
return ApplicationDeployment.IsNetworkDeployed
? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString()
: Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
发布于 2011-09-12 09:00:55
有三个版本:程序集、文件和产品。要获取产品版本,请执行以下操作:
using System.Reflection;
using System.Diagnostics;
Assembly assembly = Assembly.GetExecutingAssembly();
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
string version = fileVersionInfo.ProductVersion;
发布于 2016-06-18 13:13:12
System.Reflection.Assembly.GetEntryAssembly().GetName().Version
https://stackoverflow.com/questions/6493715
复制相似问题