473,386 Members | 1,715 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.

How can I display build number?

I'm wondering how I can access the version info within AssemblyInfo.cs
in my program? I'd like to output the version of my program in a text
label but I can't find any clear examples on how to do this.

Thanks!

AF

Nov 15 '05 #1
9 41670
Some of this information is available in the Application and Environment
objects in System.Windows.Forms, but some of this information can only be
obtained by using reflection on your assembly, like this:

object[] attrs =
System.Reflection.Assembly.GetEntryAssembly().GetC ustomAttributes(true);

foreach (object o in attrs)

if (o.GetType() == typeof(System.Reflection.AssemblyTitleAttribute))

programName = ((System.Reflection.AssemblyTitleAttribute)o).Titl e;

Chris

"Abe Frohnman" <us******@SPAMexperimentzero.org> wrote in message
news:G0*********************@news.easynews.com...
I'm wondering how I can access the version info within AssemblyInfo.cs
in my program? I'd like to output the version of my program in a text
label but I can't find any clear examples on how to do this.

Thanks!

AF

Nov 15 '05 #2
When I run this code, nothing is displayed.

Chris Capel wrote:
Some of this information is available in the Application and Environment
objects in System.Windows.Forms, but some of this information can only be
obtained by using reflection on your assembly, like this:

object[] attrs =
System.Reflection.Assembly.GetEntryAssembly().GetC ustomAttributes(true);

foreach (object o in attrs)

if (o.GetType() == typeof(System.Reflection.AssemblyTitleAttribute))

programName = ((System.Reflection.AssemblyTitleAttribute)o).Titl e;

Chris

"Abe Frohnman" <us******@SPAMexperimentzero.org> wrote in message
news:G0*********************@news.easynews.com...
I'm wondering how I can access the version info within AssemblyInfo.cs
in my program? I'd like to output the version of my program in a text
label but I can't find any clear examples on how to do this.

Thanks!

AF



Nov 15 '05 #3
This is the relevant code I have. There's a string called programName as
well.

public AboutForm()
{
InitializeComponent();

object[] attrs =
System.Reflection.Assembly.GetEntryAssembly().GetC ustomAttributes(true);

foreach (object o in attrs)
{

if (o.GetType() == typeof(System.Reflection.AssemblyTitleAttribute))

programName = ((System.Reflection.AssemblyTitleAttribute)o).Titl e;
}

Console.WriteLine("Program name is " + programName);

The only thing I can think of is that it might need to go somewhere
besides the AboutForm() constructor, but I'm not sure where else to put
it....

Chris Capel wrote:
I don't understand. You declared a string variable "programName" and called
MessageBox.Show("Program name is " + programName); ? The build version is in
a different attribute, of course. All you have to do is change the type and
the property.

Chris


Nov 15 '05 #4
Or better yet, just use System.Windows.Forms.Environment.Version. That
avoids the function call.

Chris

"Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
news:uV**************@TK2MSFTNGP11.phx.gbl...
Hi,

Try : Assembly.GetExecutingAssembly().GetName.Version , that return a
Version instance, this class implement these properties:

Public Properties
Build
Supported by the .NET Compact Framework.
Gets the value of the build component of the version number for this
instance.
Major
Supported by the .NET Compact Framework.
Gets the value of the major component of the version number for this
instance.
Minor
Supported by the .NET Compact Framework.
Gets the value of the minor component of the version number for this
instance.
Revision
Supported by the .NET Compact Framework.
Gets the value of the revision component of the version number for this instance.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Abe Frohnman" <us******@SPAMexperimentzero.org> wrote in message
news:G0*********************@news.easynews.com...
I'm wondering how I can access the version info within AssemblyInfo.cs
in my program? I'd like to output the version of my program in a text
label but I can't find any clear examples on how to do this.

Thanks!

AF


Nov 15 '05 #5
This works, but I have two more questions:

1) Is there a way I can do this so it just gets one of the properties?
ie: just major, or minor version? Or just build instead of all four?

2) In ProjectBuilder for OS X, there's a variable that keeps track of
the build number for the project. Each time the program is compiled, the
build number is incremented by one. I was hoping to find something like
that in VS NET. Yet each time I build the program, the number stays the
same. Am I looking in the wrong place?

Thanks for the help! :)

AF

Ignacio Machin wrote:
Hi,

Try : Assembly.GetExecutingAssembly().GetName.Version , that return a
Version instance, this class implement these properties:

Public Properties
Build
Supported by the .NET Compact Framework.
Gets the value of the build component of the version number for this
instance.
Major
Supported by the .NET Compact Framework.
Gets the value of the major component of the version number for this
instance.
Minor
Supported by the .NET Compact Framework.
Gets the value of the minor component of the version number for this
instance.
Revision
Supported by the .NET Compact Framework.
Gets the value of the revision component of the version number for this
instance.

Hope this help,


Nov 15 '05 #6
Does your AssemblyInfo.cs have a line that looks like this?

[assembly: AssemblyVersion("1.0.*")]

If so, the build number should increment correctly.

Chris

"Abe Frohnman" <us******@SPAMexperimentzero.org> wrote in message
news:DB*********************@news.easynews.com...
This works, but I have two more questions:

1) Is there a way I can do this so it just gets one of the properties?
ie: just major, or minor version? Or just build instead of all four?

2) In ProjectBuilder for OS X, there's a variable that keeps track of
the build number for the project. Each time the program is compiled, the
build number is incremented by one. I was hoping to find something like
that in VS NET. Yet each time I build the program, the number stays the
same. Am I looking in the wrong place?

Thanks for the help! :)

AF

Ignacio Machin wrote:
Hi,

Try : Assembly.GetExecutingAssembly().GetName.Version , that return a
Version instance, this class implement these properties:

Public Properties
Build
Supported by the .NET Compact Framework.
Gets the value of the build component of the version number for this instance.
Major
Supported by the .NET Compact Framework.
Gets the value of the major component of the version number for this instance.
Minor
Supported by the .NET Compact Framework.
Gets the value of the minor component of the version number for this instance.
Revision
Supported by the .NET Compact Framework.
Gets the value of the revision component of the version number for this instance.

Hope this help,

Nov 15 '05 #7
Yes, it has that line. When I build it the first time I get this for the
version: 1.0.1297.23935. The second time I get 1.0.1297.23983 when I was
expecting x.x.x.23936.

Chris Capel wrote:
Does your AssemblyInfo.cs have a line that looks like this?

[assembly: AssemblyVersion("1.0.*")]

If so, the build number should increment correctly.

Chris

Nov 15 '05 #8
The revision number is based on the time of day. :-) That way you always
know the relative build times of various assemblies according to their
versions. Watch it reset at midnight. :-)

Chris

"Abe Frohnman" <us******@SPAMexperimentzero.org> wrote in message
news:bM*********************@news.easynews.com...
Yes, it has that line. When I build it the first time I get this for the
version: 1.0.1297.23935. The second time I get 1.0.1297.23983 when I was
expecting x.x.x.23936.

Chris Capel wrote:
Does your AssemblyInfo.cs have a line that looks like this?

[assembly: AssemblyVersion("1.0.*")]

If so, the build number should increment correctly.

Chris


Nov 15 '05 #9
Ahh...is there a way to make the build number autoincrement?

Chris Capel wrote:
The revision number is based on the time of day. :-) That way you always
know the relative build times of various assemblies according to their
versions. Watch it reset at midnight. :-)

Chris

Nov 15 '05 #10

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

Similar topics

3
by: fragget | last post by:
where can i find a plugin that will automatically update the build number in vs.net? thx fg
5
by: Aaron | last post by:
How does the build number works? right now my assembly is version 1.0.1235.33799 it doesn't change when i re-compiled it. Thanks.
1
by: Terry | last post by:
New to C# and the VS IDE so apologies to the old sweats for such a basic question. Is there a why to program the retrieval of the build number? I am looking to add this to an xml file every...
8
by: Robert Misiak | last post by:
Is it possible to manually change the auto-build number used in VS.NET? Thanks, Robert
8
by: S. HP | last post by:
How can I make a build number that increases for each build automatically in a ASP.NET project, as I used to have in VB 6.0 ? Regards, SAHP
2
by: Stu | last post by:
Hi, I want to write a page to track changes on a site. How do I get the build number of the site's dll from a web page? Thanks in advance. Stu
4
by: Pietro | last post by:
Thanks for the last answer, but now how can i restart the count of the Build and Revision numbers of a dll in VS.Net. Thanks Pietro
4
by: Greg Smith | last post by:
Is there a way to read the build number when you compile? I would like to display the build number on the "About" screen. Any help is greatly appreciated.
2
by: Bruce | last post by:
I have the following line in my assembly.cpp. ; The * allows the build number to be automatically included. Is there any way to reset this build number? If so, how? -- Bruce E....
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.