Monthly Archives: February 2011

How to Show Click Once version in form title text

I think it’s handy to show the version of your software sometimes in the title text of your form to make sure you can see at a glance that the click once distro is the same as the program that is currently running on a PC. In order to achieve this do the following:

Make sure add a reference in your project to System.Deployment as well as the including the using statement.  You need this in order to access some specific libraries in this assembley.

In your initialisation of your form you should check to see that the version running has been deployed by Click Once.  This means that debug versions of this won’t work but live deployed versions will – if you don’t do this you will get an exception.

See code below:

           if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            {
                    this.Text = String.Format("My Foo Program {0}",
                    System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion);
            }