all groups > vb.net upgrade > november 2004 >
You're in the

vb.net upgrade

group:

Application Version in VB.Net


Application Version in VB.Net sanfordflorida
11/16/2004 6:09:34 PM
vb.net upgrade:
In VB6, it was very easy to obtain the Version Number (Major, Minor, and
Build) of the Application at run time, by using App.Major, App.Minor, and
App.Revision.

But VB.Net does not support this. How can I get these values in VB.Net?

- Warren

Re: Application Version in VB.Net Herfried K. Wagner [MVP]
11/17/2004 1:40:15 AM
"sanfordflorida" <sanfordflorida@bellsouth.net> schrieb:
[quoted text, click to view]

Structure of version numbers and methods to determine the version number
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=versioning&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Re: Application Version in VB.Net Jay B. Harlow [MVP - Outlook]
11/17/2004 9:56:04 AM
Warren,
The "easiest" way in VB.NET to get the Version number of a VB.NET Windows
Application is to use Application.ProductVersion, Application is found in
the System.Windows.Forms namespace.

To get the "product" Version of individual Assemblies I use the following
code to get the product version of specific assemblies:

Private Function GetProductVersion(ByVal [assembly] As
System.Reflection.Assembly) As String
Dim attributes() As Object
attributes =
[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


Similarly there is a Application.ProductName that will get the name of your
Product, Application.ProductName returns the value of the
AssemblyProductAttribute found in the AssemblyInfo.vb file of your project.
If you leave this attribute its default value of blank then you get the root
namespace of the project. However if you change the attribute's value then
you will get the new value.

I normally change the AssemblyProductAttribute to a displayable value & use
Application.ProductName as my message box titles.

Note Application.ProductVersion comes from the
AssemblyInformationalVersionAttribute if you add it to your AssemblyInfo.vb
file, if you do not add AssemblyInformationalVersion, the
Application.ProductVersion comes from the AssemblyVersionAttribute:

For example, if my root namespace is "TheGreatAndWonderfulApp", I might set
my AssemblyInfo.vb file as:

' somewhere in the AssemblyInfo.vb file:
....
<Assembly: AssemblyProduct("The Great & Wonderful Application")>
....
<Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyInformationalVersion("1.0.0")> ' Product Version

Hope this helps
Jay



[quoted text, click to view]

AddThis Social Bookmark Button