Welcome Guest ( Log In | Register )



 
Closed TopicStart new topic
> VB.NET: How To Find Application Build Version
tansqrx
post May 11 2005, 10:06 PM
Post #1


Super Member
Group Icon

Group: [HOSTED]
Posts: 557
Joined: 25-April 05
Member No.: 4,374
myCENTs:17.04



This seams pretty simple but I can't seam to find it out on the net. I would like to include the build information in my help dialogue box.

Ex.

----------------------------
| Welcome to help |
| Build 132 |
----------------------------

after the next recompile

----------------------------
| Welcome to help |
| Build 133 |
----------------------------

Sorry for the cheesey ascii but I figured it would be the best to get my point across.

This post has been edited by microscopic^earthling: May 12 2005, 09:44 AM
Go to the top of the page
 
+Quote Post
wykked_dreamz
post May 12 2005, 03:13 AM
Post #2


Member - Active Contributor
Group Icon

Group: Members
Posts: 83
Joined: 8-May 05
From: Neopets!
Member No.: 4,843



tansqrx im not sure i understand what you are saying. what are you trying to build? the ascii is fine but i dont think that your point got across to me. sorrie, im a little slow at times.
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post May 12 2005, 08:15 AM
Post #3


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411
myCENTs:84.36



Hi tansqrx,
    Here's your solution...

First of all your AssemblyInfo.vb contains all information on your Version/Major/Minor Builds etc.
If you take a look into that file you'll see:
QUOTE
' Version information for an assembly consists of the following four values:
'
'      Major Version
'      Minor Version
'      Build Number
'      Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:

<Assembly: AssemblyVersion("1.0.0.0")>


Now .NET provides you with a prebuilt class called FileVersionInfo which fetches this information out of your assembly or ANY given executable file.. Here's a little code-snippet that demonstrates this:

CODE

Dim myBuildInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo(Application.ExecutablePath)

MsgBox("Product build part number: " &  myBuildInfo.ProductBuildPart)


The the method named GetVersionInfo of this class fetches the information from an exe file which is specified within the paranthesis () - in this example I've used Application.ExecutablePath - which returns the path of the currently executing program including the filename - i.e. the program in which you're using this code.

The MsgBox displays the Build Information by calling the ProductBuildPart method - which extracts the build information from the Version string - of the format a.b.c.d - here the part contained in "c" is your Build Version. Use this same routine to populate your Help box.

Reminder: You'll have to upgrade the build number in your AssemblyInfo.vb file too - by default when you start writing a new application, it's set to as 1.0.0.0 - if you don't change this, your product build will always get reported as "0" or whatever you set the last build number too - this doesn't get updated automatically upon subsequent recompiles. This has to be done manually.

Don't forget to experiment with the other members of this class - they enable you to extract the Major-Minor Version/Revision info and other stats from the version string too...

Hope this helps smile.gif

Regards,
m^e

P.S. Don't look so far tongue.gif It's right there in your MSDN libraries.. just a simple search for Version Infomation would have got you the results wink.gif I was in the same shoes as you an year back tongue.gif
Go to the top of the page
 
+Quote Post
tansqrx
post May 12 2005, 10:30 PM
Post #4


Super Member
Group Icon

Group: [HOSTED]
Posts: 557
Joined: 25-April 05
Member No.: 4,374
myCENTs:17.04



As always thank you microscopic^earthling.
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post May 18 2005, 09:37 AM
Post #5


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411
myCENTs:84.36



Glad that helped. smile.gif Issue resolved. Topic closed.
Go to the top of the page
 
+Quote Post

Closed TopicStart new topic

Collapse

> Similar Topics

Topics Topics


 



- Lo-Fi Version Time is now: 2nd December 2008 - 01:27 AM