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?
To publish your app from Visual Studio, do the following: Change the solution configuration from Debug to Release on the toolbar to build a Release (rather than a Debug) version of your app. Right-click on the project (not the solution) in Solution Explorer and select Publish. In the Publish tab, select Publish.
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);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With