Application version/build number?

Hi,
How do I programatically  retrieve the version of my application to display in an "About" form, i.e. Major Version, Minor Version, Build Number or Revision? Is this possible? Thanks, Pete.
LVL 2
sumo_the_catAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Public Function GetProductVersion(ByVal [assembly] As System.Reflection.Assembly) As String

     Dim attributes() As Object = [assembly].GetCustomAttributes( _
          GetType(System.Reflection.AssemblyInformationalVersionAttribute),False)

     If attributes.Length > 0 Then
          Dim assemblyProductVersion As System.Reflection.AssemblyInformationalVersionAttribute = _
              DirectCast(attributes(0),System.Reflection.AssemblyInformationalVersionAttribute)

         Return assemblyProductVersion.InformationalVersion
     Else
         Return String.Empty
     End If

End Function

Bob
0
sumo_the_catAuthor Commented:
Hmm? What do I pass in, bob?
Label1.Text = GetProductVersion(  ?  )
0
sumo_the_catAuthor Commented:
... and what goes in place of [assembly] ?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

LacutahCommented:
Here's a simpler way to access it directly from your application:
System.Reflection.Assembly.GetExecutingAssembly.GetName.Version.Major
System.Reflection.Assembly.GetExecutingAssembly.GetName.Version.Minor
System.Reflection.Assembly.GetExecutingAssembly.GetName.Version.Build
System.Reflection.Assembly.GetExecutingAssembly.GetName.Version.Revision
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sumo_the_catAuthor Commented:
Sorry bob, just a quicky...! Thanks both, Pete.
0
sumo_the_catAuthor Commented:
For future searchers wanting the quick, definitive answer:

System.Reflection.GetExecutingAssembly.GetName.Version.ToString()

gives exactly what I need (e.g., 1.0.1788.33156)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.