I would like to show the publish version of my desktop application. I am trying to do it with this code:
_appVersion.Content = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
The problem is that I am not getting exactly the publish version I have in my project properties. Below is a screenshot of it:
But I am getting 3.0.0.12546
. Does someone know where is the problem?
We can create one property which will return the Version information as mention below and we can use that property.
public string VersionLabel
{
get
{
if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
{
Version ver = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion;
return string.Format("Product Name: {4}, Version: {0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision, Assembly.GetEntryAssembly().GetName().Name);
}
else
{
var ver = Assembly.GetExecutingAssembly().GetName().Version;
return string.Format("Product Name: {4}, Version: {0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision, Assembly.GetEntryAssembly().GetName().Name);
}
}
}