473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Version Number

Is there a way to detect the version number (from the Setup portion) of my
project?

I would like to do something like this...

label1.Text=VersionNumber;

Nov 16 '05 #1
4 7648
Notice that assemblies have 2 versions:

- AssemblyVersionAttribute: the version of the assembly. This attribute
always appears in the assemblyinfo.cs file.
- AssemblyFileVersionAttribute: the Win32 version of the file (if omitted,
it is set to the assembly version)

To get the first. you must get the executing assembly with
System.Reflection.Assembly.GetExecutingAssembly() and then the GetName()
method returns an AssemblyName object which has a Version property.

To get the second, once you have the executing assembly you can retrieve its
attributes until you find the AssemblyFileVersionAttribute attribute.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
"Keith Smith" <ke*********@verizon.net> escribió en el mensaje
news:L0oOd.14782$uc.5158@trnddc02...
Is there a way to detect the version number (from the Setup portion) of my
project?

I would like to do something like this...

label1.Text=VersionNumber;

Nov 16 '05 #2
Carlos,
In addition to AssemblyVersionAttribute & AssemblyFileVersionAttribute,
there is AssemblyInformationalVersionAttribute, aka Product Version.

If your AssemblyInfo.cs (AssemblyInfo.vb) file includes
AssemblyInformationalVersionAttribute, then
System.Windows.Forms.Application.ProductVersion will return the
Informational version otherwise it returns the AssemblyVersionAttribute.
AssemblyInformationalVersionAttribute is also used for the Product version
under Windows Explorer properties.

Normally I assign the same AssemblyInformationalVersionAttribute value to
each of my projects within a solution, which I also use in the Setup
Project.

Hope this helps
Jay


"Carlos J. Quintero [.NET MVP]" <ca*****@NOSPAMsogecable.com> wrote in
message news:u0**************@TK2MSFTNGP12.phx.gbl...
Notice that assemblies have 2 versions:

- AssemblyVersionAttribute: the version of the assembly. This attribute
always appears in the assemblyinfo.cs file.
- AssemblyFileVersionAttribute: the Win32 version of the file (if
omitted, it is set to the assembly version)

To get the first. you must get the executing assembly with
System.Reflection.Assembly.GetExecutingAssembly() and then the GetName()
method returns an AssemblyName object which has a Version property.

To get the second, once you have the executing assembly you can retrieve
its attributes until you find the AssemblyFileVersionAttribute attribute.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
"Keith Smith" <ke*********@verizon.net> escribió en el mensaje
news:L0oOd.14782$uc.5158@trnddc02...
Is there a way to detect the version number (from the Setup portion) of
my project?

I would like to do something like this...

label1.Text=VersionNumber;


Nov 16 '05 #3
> "Carlos J. Quintero [.NET MVP]" <ca*****@NOSPAMsogecable.com> wrote in
message news:u0**************@TK2MSFTNGP12.phx.gbl...
Notice that assemblies have 2 versions:

- AssemblyVersionAttribute: the version of the assembly. This attribute
always appears in the assemblyinfo.cs file.
- AssemblyFileVersionAttribute: the Win32 version of the file (if
omitted, it is set to the assembly version)

To get the first. you must get the executing assembly with
System.Reflection.Assembly.GetExecutingAssembly() and then the GetName()
method returns an AssemblyName object which has a Version property.

To get the second, once you have the executing assembly you can retrieve
its attributes until you find the AssemblyFileVersionAttribute attribute.


I tried using this code, but that didn't get me the same version as my
Setup1 project (which is version 1.0.1). What am I doing wrong?

MessageBox.Show(System.Windows.Forms.Application.P roductVersion.ToString());

Nov 16 '05 #4
Keith,
MessageBox.Show(System.Windows.Forms.Application.P roductVersion.ToString());


You need to explicitly (manually) set AssemblyInformationalVersionAttribute
to the exact same value as the Setup Project.

I normally put AssemblyInformationalVersionAttribute in the AssemblyInfo.cs
file.

I normally set both when I am ready to release a build of the solution.

Hope this helps
Jay

"Keith Smith" <ke*********@verizon.net> wrote in message
news:fyvOd.16926$wc.4205@trnddc07...
"Carlos J. Quintero [.NET MVP]" <ca*****@NOSPAMsogecable.com> wrote in
message news:u0**************@TK2MSFTNGP12.phx.gbl...
Notice that assemblies have 2 versions:

- AssemblyVersionAttribute: the version of the assembly. This attribute
always appears in the assemblyinfo.cs file.
- AssemblyFileVersionAttribute: the Win32 version of the file (if
omitted, it is set to the assembly version)

To get the first. you must get the executing assembly with
System.Reflection.Assembly.GetExecutingAssembly() and then the
GetName() method returns an AssemblyName object which has a Version
property.

To get the second, once you have the executing assembly you can retrieve
its attributes until you find the AssemblyFileVersionAttribute
attribute.


I tried using this code, but that didn't get me the same version as my
Setup1 project (which is version 1.0.1). What am I doing wrong?

MessageBox.Show(System.Windows.Forms.Application.P roductVersion.ToString());

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: mekim | last post by:
Hello....I am trying to System.Reflection.Assembly.GetExecutingAssembly ().GetName ().Version.ToString () ; to display the version of the app...but it remains static and therefore does not...
4
by: John | last post by:
Hi Is there a way to get the version number of my vb.net app, that is provided by vs? Thanks Regards
8
by: John | last post by:
Hi How can I change the product version number that is returned by Application.ProductVersion? Thanks Regards
12
by: joanne | last post by:
how to tell application version after i installed it at client side? i did make the version and product code while doing the packaging and deployment. Thanks a lot.
4
by: Dave Cullen | last post by:
Where in a VB.NET project do you get to set the version properties of your executable? Version number, Copyright, biuld comments, etc (the stuff that shows up when you right-click...
3
by: Jeff | last post by:
I've been looking and looking for how to set the version numbers for my visual studio project...where the heck is it? Used to be able to do it from project properties in VB6. I found out how to...
0
by: ev951 | last post by:
I am not that familiar with XML or XSL and I am trying to sort application version number strings in an XML file that my team uses for application installations on our Linux servers. I have tried...
6
by: Gavin Sullivan | last post by:
I've been using the date (in YMMDD) format for the build number in the AssemblyVersion attribute. However, it appears that numbers 65534 are invalid!! Bit of a bummer for 2007!!! Is there a...
1
by: ewingate | last post by:
I cannot seem to get the version number of my VB app to increment properly in VS2005. When I build the app each day the "build" number increments with no problem as does the version number but if I...
14
by: Phil | last post by:
I have been using this code to display the version number, and this has worked well, but I am now changing from using the ClickOnce publishing to a proper setup project, and this no longer works. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.