Show publish version in ClickOnce WPF or WinForms application

When deploying ClickOnce application to the client, usually there is a requirement to display application version. It’s possible to hardcode application version in configuration file, or use assembly version. But when deploying ClickOnce application Visual studio can generate publish version and automatically increment revision every time you publish ClickOnce application. So it’s better to use publish version as application version. But how to display publish version in ClickOnce application if publish version will be available only after publish is done? It’s very easy with System.Deployment namespace. Below is the C# code to display publish version in ClickOnce application.

System.Deployment.Application namespace located in System.Deployment.dll which is not referenced by default, so do not forget to add reference to System.Deployment.dll
Also you always have to check IsNetworkDeployed property, because if it’s runs locally this property is false and CurrentDeployment will throw exception.


Social media


Latest Tweets