Click Once - How to get version

I have a clickonce app in VS 2005 that I am trying to print the current version number for. If I do this:

System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();

Then I get the error:

Application Identity not set.

What gives?

[365 byte] By [KeithElder] at [2007-12-16]
# 1

Hi Keith,

The property your are using is correct. Is you app ClickOnce deployed. You can try the following code to get the version

if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)

{

string s = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion;
}
else
{
MessageBox.Show("Not a Clickonce deployed app");
}

Thanks,
Sameer

SameerMurudkar at 2007-9-9 > top of Msdn Tech,Windows Forms,ClickOnce and Setup & Deployment Projects...