BizVB

Getting the version from a ClickOnce published application

Do you get the requirement to put the version in the title bar of your apps?  I do all the time.  With the advent of ClickOnce, though, most apps have TWO version numbers, the Assembly Version, and the Publish Version.  If you go by the Publish Version (you aren't alone) you can get the Version number using the System.Deployment.Application namespace.  Make sure you import it first, and reference it too.

If ApplicationDeployment.IsNetworkDeployed Then
  Me.Text = String.Format("{0}, Version {1}", Me.Text, ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString)
Else
  Me.Text = String.Format("{0}, Version {1}.{2}.{3}.{4}", Me.Text, My.Application.Info.Version.Major.ToString, My.Application.Info.Version.Minor.ToString, My.Application.Info.Version.Build.ToString, My.Application.Info.Version.Revision.ToString)
End If 

Comments are closed
Mastodon