Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. At runtime find the application's build version?

At runtime find the application's build version?

Scheduled Pinned Locked Moved C#
regexquestionannouncement
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JollyMansArt
    wrote on last edited by
    #1

    Is it possible to pull from somewhere after the application has been compiled to know what it's build version number is so I can show it in a label? I am thinking I can pull if from the assembly but my attempts have failed. Please can someone point me in the right direction? Here is what I am currently doing and it does not match the build version of the application that I am compiling. lblAppVersion.Text = "Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " or " + System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString();

    R D C 3 Replies Last reply
    0
    • J JollyMansArt

      Is it possible to pull from somewhere after the application has been compiled to know what it's build version number is so I can show it in a label? I am thinking I can pull if from the assembly but my attempts have failed. Please can someone point me in the right direction? Here is what I am currently doing and it does not match the build version of the application that I am compiling. lblAppVersion.Text = "Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " or " + System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString();

      R Offline
      R Offline
      ricmil42
      wrote on last edited by
      #2

      Are you looking for something like this?

      labelControlVersion.Text = string.Format ( "Version: {0}", Assembly.GetExecutingAssembly ( ).GetName ( ).Version ) ;

      J 1 Reply Last reply
      0
      • R ricmil42

        Are you looking for something like this?

        labelControlVersion.Text = string.Format ( "Version: {0}", Assembly.GetExecutingAssembly ( ).GetName ( ).Version ) ;

        J Offline
        J Offline
        JollyMansArt
        wrote on last edited by
        #3

        Not quite I want the applications build version... which would show on the project properties screen under the publish tab. any idea where this is?

        1 Reply Last reply
        0
        • J JollyMansArt

          Is it possible to pull from somewhere after the application has been compiled to know what it's build version number is so I can show it in a label? I am thinking I can pull if from the assembly but my attempts have failed. Please can someone point me in the right direction? Here is what I am currently doing and it does not match the build version of the application that I am compiling. lblAppVersion.Text = "Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " or " + System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString();

          D Offline
          D Offline
          Dougie the P
          wrote on last edited by
          #4

          What do you want the text in the label to look like? To Get This "Ver. 5.1.2 Rev. 3" Try like this; Dim avi As System.Version = System.Reflection.Assembly.GetExecutingAssembly.GetName.Version lblVersion.Text = "Ver. " & Format(avi.Major, "###0").TrimEnd & "." _ & Format(avi.Minor, "###0").TrimEnd & "." & Format(avi.Build, "###0").TrimEnd _ & " Rev. " & Format(avi.Revision, "###0") Of course this is not the publish version (just saw last post)

          1 Reply Last reply
          0
          • J JollyMansArt

            Is it possible to pull from somewhere after the application has been compiled to know what it's build version number is so I can show it in a label? I am thinking I can pull if from the assembly but my attempts have failed. Please can someone point me in the right direction? Here is what I am currently doing and it does not match the build version of the application that I am compiling. lblAppVersion.Text = "Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " or " + System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString();

            C Offline
            C Offline
            Cracked Down
            wrote on last edited by
            #5

            it is very easy tog et this info This is a code for this

            //get the version from the assemblyinfo.cs
            // Version information for an assembly consists of the following four values:
            //
            // Major Version
            // Minor Version
            // Build Number
            // Revision
            //
            Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            //add to label
            lblVersion.Text = v.ToString();

            This information is stored in the AssemblyInfo.cs under Node 'Properties' in Solution explorer! :) Reg, Deep Happy Coding!

            J 1 Reply Last reply
            0
            • C Cracked Down

              it is very easy tog et this info This is a code for this

              //get the version from the assemblyinfo.cs
              // Version information for an assembly consists of the following four values:
              //
              // Major Version
              // Minor Version
              // Build Number
              // Revision
              //
              Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
              //add to label
              lblVersion.Text = v.ToString();

              This information is stored in the AssemblyInfo.cs under Node 'Properties' in Solution explorer! :) Reg, Deep Happy Coding!

              J Offline
              J Offline
              JollyMansArt
              wrote on last edited by
              #6

              Thanks I learned that c# does not auto increment the version per each build. That was the issue I was having.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups