-
How Do I Display Application's Version Info?
In VB6, it was easy to display the app's version information (major, minor,
revision) in a textbox or a label.
All I had to do (if I recall correctly) is the following:
Let's say I want to display major version info in a label called "label1":
label1.caption=app.major
Likewise, I could concatenate the version info strings (major, minor, etc)
into one string and display it just as easily.
I have yet to figure out how to do this with VB.NET.
Suppose I have a label called "lblVersion".
How would I display all of the available application version information
within this label?
All I want is a line of text displayed on my app's form that looks similar
to the following:
"Version 1.0.0.1"
Thanks,
Jim Graham
--
graham@iucf.indiana.edu
-
Re: How Do I Display Application's Version Info?
lblVersion.Text = "Version " & Application.ProductVersion
Should do the trick.. . .
--
Jacob Grass
Microsoft .NET MVP
"James Graham" <graham@iucf.indiana.edu> wrote in message
news:3c978336$1@10.1.10.29...
>
> In VB6, it was easy to display the app's version information (major,
minor,
> revision) in a textbox or a label.
>
> All I had to do (if I recall correctly) is the following:
>
> Let's say I want to display major version info in a label called "label1":
>
> label1.caption=app.major
>
> Likewise, I could concatenate the version info strings (major, minor, etc)
> into one string and display it just as easily.
>
> I have yet to figure out how to do this with VB.NET.
>
> Suppose I have a label called "lblVersion".
>
> How would I display all of the available application version information
> within this label?
>
> All I want is a line of text displayed on my app's form that looks similar
> to the following:
>
> "Version 1.0.0.1"
>
> Thanks,
> Jim Graham
> --
> graham@iucf.indiana.edu
>
-
Re: How Do I Display Application's Version Info?
Jacob, thanks for the reply.
Actually, I tried this but it causes the Microsoft Development Environment
to popup a message box stating the following:
"The following exception has occurred:
BadImageFormatException: The format of the file 'devenv.exe' is invalid."
In fact, a reference to ANY "Application.xxxxxxxxx" causes this.
Thanks,
Jim Graham
--
graham@iucf.indiana.edu
"Jacob Grass" <JGrass@AbilitiSolutions.com> wrote:
>lblVersion.Text = "Version " & Application.ProductVersion
>
>Should do the trick.. . .
>
>--
>Jacob Grass
>Microsoft .NET MVP
>
>"James Graham" <graham@iucf.indiana.edu> wrote in message
>news:3c978336$1@10.1.10.29...
>>
>> In VB6, it was easy to display the app's version information (major,
>minor,
>> revision) in a textbox or a label.
>>
>> All I had to do (if I recall correctly) is the following:
>>
>> Let's say I want to display major version info in a label called "label1":
>>
>> label1.caption=app.major
>>
>> Likewise, I could concatenate the version info strings (major, minor,
etc)
>> into one string and display it just as easily.
>>
>> I have yet to figure out how to do this with VB.NET.
>>
>> Suppose I have a label called "lblVersion".
>>
>> How would I display all of the available application version information
>> within this label?
>>
>> All I want is a line of text displayed on my app's form that looks similar
>> to the following:
>>
>> "Version 1.0.0.1"
>>
>> Thanks,
>> Jim Graham
>> --
>> graham@iucf.indiana.edu
>>
>
>
-
Re: How Do I Display Application's Version Info?
James-
I do believe that this error is indicative of a bad install.
--
Jacob Grass
Microsoft .NET MVP
"James Graham" <graham@iucf.indiana.edu> wrote in message
news:3c97980f$1@10.1.10.29...
>
> Jacob, thanks for the reply.
>
> Actually, I tried this but it causes the Microsoft Development Environment
> to popup a message box stating the following:
>
> "The following exception has occurred:
> BadImageFormatException: The format of the file 'devenv.exe' is invalid."
>
> In fact, a reference to ANY "Application.xxxxxxxxx" causes this.
>
> Thanks,
> Jim Graham
> --
> graham@iucf.indiana.edu
>
>
> "Jacob Grass" <JGrass@AbilitiSolutions.com> wrote:
> >lblVersion.Text = "Version " & Application.ProductVersion
> >
> >Should do the trick.. . .
> >
> >--
> >Jacob Grass
> >Microsoft .NET MVP
> >
> >"James Graham" <graham@iucf.indiana.edu> wrote in message
> >news:3c978336$1@10.1.10.29...
> >>
> >> In VB6, it was easy to display the app's version information (major,
> >minor,
> >> revision) in a textbox or a label.
> >>
> >> All I had to do (if I recall correctly) is the following:
> >>
> >> Let's say I want to display major version info in a label called
"label1":
> >>
> >> label1.caption=app.major
> >>
> >> Likewise, I could concatenate the version info strings (major, minor,
> etc)
> >> into one string and display it just as easily.
> >>
> >> I have yet to figure out how to do this with VB.NET.
> >>
> >> Suppose I have a label called "lblVersion".
> >>
> >> How would I display all of the available application version
information
> >> within this label?
> >>
> >> All I want is a line of text displayed on my app's form that looks
similar
> >> to the following:
> >>
> >> "Version 1.0.0.1"
> >>
> >> Thanks,
> >> Jim Graham
> >> --
> >> graham@iucf.indiana.edu
> >>
> >
> >
>
-
Re: How Do I Display Application's Version Info?
Unless you are doing something with a Managed C++ app?
http://support.microsoft.com/default...;en-us;Q309692
--
Jacob Grass
Microsoft .NET MVP
"Jacob Grass" <JGrass@AbilitiSolutions.com> wrote in message
news:3c979c87$1@10.1.10.29...
> James-
>
> I do believe that this error is indicative of a bad install.
>
> --
> Jacob Grass
> Microsoft .NET MVP
>
> "James Graham" <graham@iucf.indiana.edu> wrote in message
> news:3c97980f$1@10.1.10.29...
> >
> > Jacob, thanks for the reply.
> >
> > Actually, I tried this but it causes the Microsoft Development
Environment
> > to popup a message box stating the following:
> >
> > "The following exception has occurred:
> > BadImageFormatException: The format of the file 'devenv.exe' is
invalid."
> >
> > In fact, a reference to ANY "Application.xxxxxxxxx" causes this.
> >
> > Thanks,
> > Jim Graham
> > --
> > graham@iucf.indiana.edu
> >
> >
> > "Jacob Grass" <JGrass@AbilitiSolutions.com> wrote:
> > >lblVersion.Text = "Version " & Application.ProductVersion
> > >
> > >Should do the trick.. . .
> > >
> > >--
> > >Jacob Grass
> > >Microsoft .NET MVP
> > >
> > >"James Graham" <graham@iucf.indiana.edu> wrote in message
> > >news:3c978336$1@10.1.10.29...
> > >>
> > >> In VB6, it was easy to display the app's version information (major,
> > >minor,
> > >> revision) in a textbox or a label.
> > >>
> > >> All I had to do (if I recall correctly) is the following:
> > >>
> > >> Let's say I want to display major version info in a label called
> "label1":
> > >>
> > >> label1.caption=app.major
> > >>
> > >> Likewise, I could concatenate the version info strings (major, minor,
> > etc)
> > >> into one string and display it just as easily.
> > >>
> > >> I have yet to figure out how to do this with VB.NET.
> > >>
> > >> Suppose I have a label called "lblVersion".
> > >>
> > >> How would I display all of the available application version
> information
> > >> within this label?
> > >>
> > >> All I want is a line of text displayed on my app's form that looks
> similar
> > >> to the following:
> > >>
> > >> "Version 1.0.0.1"
> > >>
> > >> Thanks,
> > >> Jim Graham
> > >> --
> > >> graham@iucf.indiana.edu
> > >>
> > >
> > >
> >
>
>
-
Re: How Do I Display Application's Version Info?
> Unless you are doing something with a Managed C++ app?
^^
Un
--
Jacob Grass
Microsoft .NET MVP
-
Re: How Do I Display Application's Version Info?
Not that I can tell.
I've installed vs.net on a different machine just to see if there was a "bad
install". I get the same symptoms.
However, I've observed some new behavior which I (being new to VB.net) certainly
cannot explain.
The code:
lblVersion.text=Application.ProductVersion
actually works, reporting the information requested and with no errors.
However, this only true for a project developed using the "Windows Application"
template. What I'm developing is a project using the "Windows Control Library"
template. THIS is where the problem occurs.
I'm developing a control to display a virtual "LED" indicator. The control
has a number of custom properties defined by me. One of those properties
is to display an "About" window. It is on this "About" window from that
I'm trying to display the version of the usercontrol.
To test, I have brought in a "test" form on which I can place my new control.
I drop a control onto the form, then I double-click on the control's "About"
property and up pops my "About" window, but shortly prior to that, I get
the devenv.exe error.
I mentioned earlier that the "Application.ProductVersion" works in a normal
windows application form. However, it bombs if I try to place my custom
control on the application's main form, but textbox, label and other Microsoft
controls seem to be happy when I invoke the above. This tells me it's something
I'm doing wrong with my custom control...at design-time. Maybe it's simple.
Maybe I'm not supposed to use the "Application.ProductVersion" call from
a usercontrol????
Thanks,
Jim Graham
--
graham@iucf.indiana.edu
"Jacob Grass" <JGrass@AbilitiSolutions.com> wrote:
>> Unless you are doing something with a Managed C++ app?
>
^^
>
Un
>
>
>--
>Jacob Grass
>Microsoft .NET MVP
>
>
>
-
Re: How Do I Display Application's Version Info?
James-
Okay, that helps narrow down the problem a bit. The Application class is
really only applicable in a situation where a MessageLoop is being created.
This occurs with Windows Applications, not Class/Control libraries or
UserControls. UserControls (Control libraries) versioning info exists in
the AssemblyInfo.vb file. I am not sure how to retreive this information at
runtime. Perhaps someone else can chime in with their expertise.
--
Jacob Grass
Microsoft .NET MVP
"James Graham" <graham@iucf.indiana.edu> wrote in message
news:3c98d07e$1@10.1.10.29...
>
> Not that I can tell.
> I've installed vs.net on a different machine just to see if there was a
"bad
> install". I get the same symptoms.
>
> However, I've observed some new behavior which I (being new to VB.net)
certainly
> cannot explain.
>
> The code:
> lblVersion.text=Application.ProductVersion
>
> actually works, reporting the information requested and with no errors.
>
> However, this only true for a project developed using the "Windows
Application"
> template. What I'm developing is a project using the "Windows Control
Library"
> template. THIS is where the problem occurs.
>
> I'm developing a control to display a virtual "LED" indicator. The
control
> has a number of custom properties defined by me. One of those properties
> is to display an "About" window. It is on this "About" window from that
> I'm trying to display the version of the usercontrol.
>
> To test, I have brought in a "test" form on which I can place my new
control.
> I drop a control onto the form, then I double-click on the control's
"About"
> property and up pops my "About" window, but shortly prior to that, I get
> the devenv.exe error.
>
> I mentioned earlier that the "Application.ProductVersion" works in a
normal
> windows application form. However, it bombs if I try to place my custom
> control on the application's main form, but textbox, label and other
Microsoft
> controls seem to be happy when I invoke the above. This tells me it's
something
> I'm doing wrong with my custom control...at design-time. Maybe it's
simple.
> Maybe I'm not supposed to use the "Application.ProductVersion" call from
> a usercontrol????
>
> Thanks,
> Jim Graham
> --
> graham@iucf.indiana.edu
>
>
>
> "Jacob Grass" <JGrass@AbilitiSolutions.com> wrote:
> >> Unless you are doing something with a Managed C++ app?
> >
> ^^
> >
> Un
> >
> >
> >--
> >Jacob Grass
> >Microsoft .NET MVP
> >
> >
> >
>
-
Re: How Do I Display Application's Version Info?
>UserControls (Control libraries) versioning info exists in
>the AssemblyInfo.vb file. I am not sure how to retreive this information at
>runtime. Perhaps someone else can chime in with their expertise.
AssemblyVersionAttribute is a pseudo-custom attribute that ends up
being part of the assembly name. It can be retrieved with
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version
Other Assembly* attributes can be retrieved with
System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes()
Mattias
===
Mattias Sjögren (VB MVP)
mattias @ mvps.org
http://www.msjogren.net/dotnet/
-
Re: How Do I Display Application's Version Info?
Mattias,
Thank you for your help.
I've got it all working now. I had to massage your suggestion to get it
to work. In particular, I had to be more explicit in terms of getting the
version information.
In particular, I had to do the following....
----------------------
Dim strMajorVersion, strMinorVersion, strBuildVersion, strRevisionVersion_
As String
strMajorVersion = System.Reflection.Assembly.GetExecutingAssembly_().GetName().Version.Major()
strMinorVersion = System.Reflection.Assembly.GetExecutingAssembly_().GetName().Version.Minor()
strBuildVersion = System.Reflection.Assembly.GetExecutingAssembly_().GetName().Version.Build()
strRevisionVersion=System.Reflection.Assembly.GetExecutingAssembly_().GetName().Version.Re vision()
lblVersion.Text = "Version - " & strMajorVersion & "." & strMinorVersion_
& "." & strBuildVersion & "." & strRevisionVersion
--------------------------------------------------
Again, I wish to thank both you and Jacob for your help!
Regards,
Jim Graham
--
graham@iucf.indiana.edu
Mattias Sjögren <mattias.dont.want.spam@mvps.org> wrote:
>
>>UserControls (Control libraries) versioning info exists in
>>the AssemblyInfo.vb file. I am not sure how to retreive this information
at
>>runtime. Perhaps someone else can chime in with their expertise.
>
>
>AssemblyVersionAttribute is a pseudo-custom attribute that ends up
>being part of the assembly name. It can be retrieved with
>
>System.Reflection.Assembly.GetExecutingAssembly().GetName().Version
>
>Other Assembly* attributes can be retrieved with
>
>System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes()
>
>
>Mattias
>
>===
>Mattias Sjögren (VB MVP)
>mattias @ mvps.org
>http://www.msjogren.net/dotnet/
-
Re: How Do I Display Application's Version Info?
James,
>In particular, I had to do the following....
>----------------------
>Dim strMajorVersion, strMinorVersion, strBuildVersion, strRevisionVersion_
>As String
>
>strMajorVersion = System.Reflection.Assembly.GetExecutingAssembly_().GetName().Version.Major()
>strMinorVersion = System.Reflection.Assembly.GetExecutingAssembly_().GetName().Version.Minor()
>strBuildVersion = System.Reflection.Assembly.GetExecutingAssembly_().GetName().Version.Build()
>strRevisionVersion=System.Reflection.Assembly.GetExecutingAssembly_().GetName().Version.R evision()
>
>lblVersion.Text = "Version - " & strMajorVersion & "." & strMinorVersion_
>& "." & strBuildVersion & "." & strRevisionVersion
>
>--------------------------------------------------
I believe you can shorten that to
lblVersion.Text = "Version - " & _
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()
Mattias
===
Mattias Sjögren (VB MVP)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|