Add the link to the library System.Deploymentto your project and edit this piece of code:
using System.Deployment.Application;
and
string version = null;
try
{
version = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
}
catch (InvalidDeploymentException)
{
version = "not installed";
}
As stated in the comment, you cannot get the publication version during debugging, so I suggest processing InvalidDeploymentException.
source
share