Accessing application versions
In .NET, an application has a number of different versions and so, we have a number of alternative ways to access them. The version number that we discussed earlier and is displayed in the Publish Version section of the Publish tab of the project properties can be found using the ApplicationDeployment
class from the System.Deployment
DLL.
using System.Deployment.Application; ... private string GetPublishedVersion() { if (ApplicationDeployment.IsNetworkDeployed) { return ApplicationDeployment.CurrentDeployment.CurrentVersion. ToString(); } return "Not network deployed"; }
Note that we need to verify that the application has actually been deployed before we can access the CurrentVersion
property of the ApplicationDeployment ...
Get Mastering Windows Presentation Foundation now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.