You can use the following test
if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) {
return System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion;
}
to avoid the exception (as detailed in this post).
Also, I don’t think you can get the current publish version via Visual Studio debugging because accessing CurrentDeployment will throw an InvalidDeploymentException.