How to get the publish version [Major,Minor,Built,Revision]



    I`d like to now how to get the publish version that apears in the project properties.


    I have tried the following code:


    this.label2.Text = Application.ProductVersion.ToString();

    but it appears to get a different version, it gets the version of the dlls (1.0.2753.27079) and i want the version of project properties.


    Can anyone help?

    Monday, July 16, 2007 4:51 PM


  • Try something like this.


    Code Snippet

    Version version = Application.ProductionVersion;
    if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) {
      System.Deployment.Application.ApplicationDeployment ad = System.Deployment.Application.ApplicationDeploymen t.CurrentDeployment;
      version = ad.CurrentVersion;



    Monday, July 16, 2007 10:25 PM

All replies

  • I give an example on my blog entitled Extracting the Assembly Version in .Net, but you need to extract the information using reflection from the current assembly.
    Monday, July 16, 2007 5:35 PM
  • Try something like this.


    Code Snippet

    Version version = Application.ProductionVersion;
    if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) {
      System.Deployment.Application.ApplicationDeployment ad = System.Deployment.Application.ApplicationDeploymen t.CurrentDeployment;
      version = ad.CurrentVersion;



    Monday, July 16, 2007 10:25 PM
  • Sorry but Application does not have a ProductionVersion and second and most important

    System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed is false.



    Tuesday, July 17, 2007 9:20 AM
  • OmegaMan how can i use reflection from the current assembly ?
    Tuesday, July 17, 2007 9:26 AM
  • Hi

    I'm not sure whether I understand you correctly, but this is what I would do:

    Code Snippet

    System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
     System.Diagnostics.Debug.WriteLine(String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Revision, version.Build));

    Hope this helps ...
    Tuesday, July 17, 2007 10:42 AM
  • sorry but I already got that result version (1.0.2754.19709). What I want is the version stated in the last application manifest that was publish. 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: 




    I hope it was clear. Please give me feedback on this! Thanks!

    Tuesday, July 17, 2007 11:28 AM
  • System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed  will only be true if you are running it from the published location. if you are running from the visual studio or directly off the disk, then it will be false. you would have to publish, and then run the published application for it to be true.


    also that was a typo on my part. i ment to type ProductVersion not ProductionVersion

    Tuesday, July 17, 2007 9:23 PM
  • Thank you it works, But i had to install the program again

    i only use the following code

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

    System.Deployment.Application.ApplicationDeployment ad = System.Deployment.Application.ApplicationDeployment.CurrentDeployment;

    this.label2.Text = ad.CurrentVersion.ToString();





    Wednesday, July 18, 2007 11:04 AM
  •  jcfmarkes wrote:
    OmegaMan how can i use reflection from the current assembly ?

    Reflection can be done on any assembly. Reflection is just a term to dynamically browse or instantiate objects at runtime. In my blog article that I mentioned, one is reflecting the assembly version information off of the current executing assembly.

    Try my code in a console application, away from your app to get a feel for how it works.
    Wednesday, July 18, 2007 2:56 PM
  • All,

    I have searched high and low for this... and this code was the best example that I found. I was able to change it to VB to work in my app. Thank you! 


    Thursday, March 10, 2011 9:14 AM
  • Thank you jcfmarkes. :)...

    This was the code that I was searching for . Thanks a lot.

    Thursday, May 05, 2011 6:16 AM
  • Hi all,
    Since I've started using ClickOnce technology, I changed my VB code to:
    Dim assem As Assembly = Assembly.GetEntryAssembly()
    Dim assemName As AssemblyName = assem.GetName()
    If System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed Then
    Dim ad As System.Deployment.Application.ApplicationDeployment = System.Deployment.Application.ApplicationDeployment.CurrentDeployment
    strVersion = ad.CurrentVersion.ToString
    strVersion = assemName.Version.ToString
    End If
    Me.Text = System.String.Format("{0} ({1})", assemName.Name, strVersion)
    Thursday, June 30, 2011 10:26 PM
  • An up-to-date guide for those finding this post today.  Works for C# Visual Studio 2010

            public string PublishVersion
                    if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
                        Version ver = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion;
                        return string.Format("{0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
                        return "Not Published";

    Sunday, February 19, 2012 9:00 AM
  • Thank you Xian!

    I adapted your code for VB 2010

        Public Function GetVersion() As String
            If (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) Then
                Dim ver As Version
                ver = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion
                Return String.Format("{0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision)
                Return "Not Published"
            End If
        End Function

    • Edited by Anglave Thursday, February 23, 2012 8:44 PM
    Thursday, February 23, 2012 8:43 PM
  • Hi 

    I'm trying the same in VB2010, but System.Deployment.Application doesn't seem to be available. The given error is 'Application is not a member of 'Deployment' . There is written  'Imports System.Deployment' at the beginning of the module.

    Does anyone have an idea about the reason?

    Thanks in advance,

    Pete Bux

    • Proposed as answer by steve.watkins Wednesday, May 27, 2015 9:37 AM
    Friday, April 06, 2012 12:19 PM
  • Hmm.  Strange you would get that message if the assembly were not referenced by the project.

    Assembly System.Deployment
        Member of .NET Framework 4
        C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Deployment.dll

    Rudy   =8^D

    Mark the best replies as answers. "Fooling computers since 1971."

    Friday, April 06, 2012 1:13 PM
  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Deployment.dll

    This file is present. The import doesn't give any errors except for 'Application is not a member of 'Deployment' when referenced to 'Application'

    Pete Bux

    Tuesday, April 10, 2012 6:46 AM
  • Add a reference to System.Deployment.
    Friday, April 12, 2013 12:56 PM
  • Thank you, I was very useful.


    Mariela 77

    Tuesday, August 27, 2013 3:53 PM