組件版本編號

讀取組件的版本編號


System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
this.lblVersion.Text = String.Format("{0}.{1}", version.Build, version.MinorRevision);


讀取 ClickOnce 部屬時的版本編號


if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
{
System.Version version = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion;
this.lblVersion.Text = String.Format("{0}.{1}.{2}", version.Minor, version.Build, version.MinorRevision);
}


版本編號有4個數字組成,依序為



  • Major : 主要
  • Minor : 次要
  • Build : 組建
  • MinorRevision : 修訂

image


參考


How to display ClickOnce Version number on Windows Forms