I'm deploying now a WPF c# project and want to put the clickonce version (rather than the assembly or product version) on the screen title. I used to do it in Win form application in the following way. But it seems that it is not the way in WPF applications. I searched on Google but didn't find anything. Please help.
if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
{
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
lblVer.Text = "V" + ad.CurrentVersion.ToString();
}
else
lblVer.Text = "V" + Application.ProductVersion.ToString();
Try this:
public static Version GetPublishedVersion()
{
XmlDocument xmlDoc = new XmlDocument();
Assembly asmCurrent = System.Reflection.Assembly.GetExecutingAssembly();
string executePath = new Uri(asmCurrent.GetName().CodeBase).LocalPath;
xmlDoc.Load(executePath + ".manifest");
string retval = string.Empty;
if (xmlDoc.HasChildNodes)
{
retval = xmlDoc.ChildNodes[1].ChildNodes[0].Attributes.GetNamedItem("version").Value.ToString();
}
return new Version(retval);
}