Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Showing project version?

Status
Not open for further replies.

RascaPR

Technical User
Oct 27, 2007
26
0
0
US
How can I set my project's version number to a variable, so that I can display it on the form? For example, I would like to be able to show the version number on the Title Bar.
 
I have a static class in my app, with all version info in one place. heres a simplified version of it:

Code:
public class Version
    {
        // Pro Version, set this flag to true if compiling the pro version
        public static bool Pro = false;

        // Update URL
        public static string UpdateURL
        {
            get
            {
                string url = "[URL unfurl="true"]http://www.mysite.com/appname/updater.cfm";[/URL]
                if (Pro)
                    url += "?Pro=1";

                return url;
            }
        }

        // Settings.xml Path
        public static string SettingsFilename = "Settings.xml";
        
        //#if DEBUG
        //    public static string SettingsPath = Application.StartupPath;
        //#else
            public static string SettingsPath = Application.UserAppDataPath;
        //#endif

        // "About ImageMapper..." Form Stuff
        public const string AboutMessage = "######## is a product of #########, " +
            "Inc. of Northville, Michigan.  For more infomation on #########, please call us at (###) ###-####";

        // Copyright
        public static string Copyright = "Copyright ©2005-" + DateTime.Now.Year.ToString() + " ########## Inc.";

        public static new string ToString()
        {
            return Application.ProductName + " " + Application.ProductVersion;
        }
    }
 
oh, i forgot to mention, the Application.ProductVersion is set in the assembly properties of the project properties page in visual studio. I turn off auto increment so I can update the version number as I see fit. It is a 4 part number, my app is currently on 1.5.0.23, it is standard to set the 4 numbers as follows:

#1 - Version Num
#2 - Major Revision
#3 - Minor Revision
#4 - Build
 
Thanks for your response!! One question though... With regards to the revision number scheme, what changes deserve a certain revision number.

For example, what type of changes warrants an updated Version Number, Major Revision, Minor Revision or a Build?
 
Typically, a Version Number increment is a complete rework/release of the application. The Major Revision is used to show Service Packs or other large changes. Minor Revisions are just small fixes here and there. Build is usually incremented with every build.

There's no hard-coded rule that says you have to increment in any particular fashion. There's an application that increments by adding a digit to the end using PI (3.1415...).
 
Also, another way to get the information you're looking for is to use the Assembly Namespace through Reflection. This will get the version number of the executing assembly. You can use this namespace to retrieve everything you want to know about the assembly.

Assembly.GetExecutingAssembly().GetName().Version.ToString();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top