At the moment I am manually updating the version field (textbox
) in my application every time I publish it. I am wondering if there is a way to have my application get that data from somewhere and display it in the box for me. I am using VS2012 and I am just unsure of how to achieve that in C#. Below is a screenshot of the VS2012 properties window that I am talking about.
NEW IMAGE:
Hover over the title of the document with your mouse, click the drop-down arrow, and click Publish a major version. The Publish Major Version dialog box opens. Enter a comment in the Comments field and then click OK. Note: Comments are optional and make it easier to find a previous version.
Click the ellipses ( ... ), click More, and then click Publish. Click the ellipses ( ... ), click the ellipses again ( ... ), click Advanced, and then click Publish a major version. Click the ellipses ( ... ), click the ellipses again ( ... ), and then click Publish a major version.
Hover over the title of the document with your mouse, click the drop-down arrow, and click Unpublish this version. When you are prompted to confirm that you want to unpublish the version, click OK.
You can see it by clicking with the right mouse button in the project and choosing its properties (see tab named "Publish"). In my case the last updadted version has the name:
Don't forget to check if the application is networkdeployed otherwise it won't work in debug mode.
if (ApplicationDeployment.IsNetworkDeployed) { this.Text = string.Format("Your application name - v{0}", ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(4)); }
Try this:
using System.Deployment.Application; public Version AssemblyVersion { get { return ApplicationDeployment.CurrentDeployment.CurrentVersion; } }
Then the caller to the getter property can de-reference the Major
, Minor
, Build
and Revision
properties, like this:
YourVersionTextBox.Text = AssemblyVersion.Major.ToString() + "." + AssemblyVersion.Minor.ToString() + "." + AssemblyVersion.Build.ToString() + "." + AssemblyVersion.Revision.ToString();
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