O'Reilly logo

Mastering Windows Presentation Foundation by Sheridan Yuen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required