VB.NET

Moderators: seancampbell
Number of threads: 4020
Number of posts: 10026

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Program version Posted by eagleman on 22 Mar 2004 at 9:08 AM

Does anyone know how to retrieve the version for a program in code when the same program is running? I would like to put the programs version in the form.name property

//Eagleman

Report
Re: Program version Posted by kainsworth on 22 Mar 2004 at 11:38 AM
This info is available direct from the Application namespace. So, eg, to display current version no in a messagebox:
MessageBox.Show(Application.ProductVersion)

All the information that is stored in the AssemblyInfo.vb is available - but some of it isn't quite so easy to get at, though.
Let me know if you want more.

================================================================


:
: Does anyone know how to retrieve the version for a program in code when the same program is running? I would like to put the programs version in the form.name property
:
: //Eagleman
:
:

Report
Re: Program version Posted by eagleman on 22 Mar 2004 at 12:44 PM
Great Ged thank you under Application I also found Application.ProductName that was usable for me but is there a way to find the copyright info in a similar way?

//Eagleman


: This info is available direct from the Application namespace. So, eg, to display current version no in a messagebox:
:
: MessageBox.Show(Application.ProductVersion)
: 

: All the information that is stored in the AssemblyInfo.vb is available - but some of it isn't quite so easy to get at, though.
: Let me know if you want more.
:
: ================================================================
:
:
: :
: : Does anyone know how to retrieve the version for a program in code when the same program is running? I would like to put the programs version in the form.name property
: :
: : //Eagleman
: :
: :
:
:

Report
Re: Program version Posted by kainsworth on 22 Mar 2004 at 2:09 PM
Hi
Here's the code I would use:
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '  Declare a variable for Sys Reflection Assy
        Dim sra As System.Reflection.Assembly
        '  Dec for the Copyright Attribute
        Dim copyrtAttr As System.Reflection.AssemblyCopyrightAttribute
        ' Get the current executing Assembly 
        sra = System.Reflection.Assembly.GetExecutingAssembly
        ' Get the Copyright Attribute via Sys Refl Assy
        copyrtAttr = sra.GetCustomAttributes(GetType(System.Reflection.AssemblyCopyrightAttribute), False)(0)
'   Display it
        Label1.Text = "CopyRight: " & copyrtAttr.Copyright
    End Sub

Cheers
Ged

=========================================================

: Great Ged thank you under Application I also found Application.ProductName that was usable for me but is there a way to find the copyright info in a similar way?
:
: //Eagleman
:
:
: : This info is available direct from the Application namespace. So, eg, to display current version no in a messagebox:
: :
: : MessageBox.Show(Application.ProductVersion)
: : 

: : All the information that is stored in the AssemblyInfo.vb is available - but some of it isn't quite so easy to get at, though.
: : Let me know if you want more.
: :
: : ================================================================
: :
: :
: : :
: : : Does anyone know how to retrieve the version for a program in code when the same program is running? I would like to put the programs version in the form.name property
: : :
: : : //Eagleman
: : :
: : :
: :
: :
:
:

Report
Re: Program version Posted by eagleman on 25 Mar 2004 at 1:32 PM

Thank you Ged I have incorporated your solution.

//Eagleman

: Hi
: Here's the code I would use:
:
: Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
:         '  Declare a variable for Sys Reflection Assy
:         Dim sra As System.Reflection.Assembly
:         '  Dec for the Copyright Attribute
:         Dim copyrtAttr As System.Reflection.AssemblyCopyrightAttribute
:         ' Get the current executing Assembly 
:         sra = System.Reflection.Assembly.GetExecutingAssembly
:         ' Get the Copyright Attribute via Sys Refl Assy
:         copyrtAttr = sra.GetCustomAttributes(GetType(System.Reflection.AssemblyCopyrightAttribute), False)(0)
: '   Display it
:         Label1.Text = "CopyRight: " & copyrtAttr.Copyright
:     End Sub
: 

: Cheers
: Ged
:
: =========================================================
:
: : Great Ged thank you under Application I also found Application.ProductName that was usable for me but is there a way to find the copyright info in a similar way?
: :
: : //Eagleman
: :
: :
: : : This info is available direct from the Application namespace. So, eg, to display current version no in a messagebox:
: : :
: : : MessageBox.Show(Application.ProductVersion)
: : : 

: : : All the information that is stored in the AssemblyInfo.vb is available - but some of it isn't quite so easy to get at, though.
: : : Let me know if you want more.
: : :
: : : ================================================================
: : :
: : :
: : : :
: : : : Does anyone know how to retrieve the version for a program in code when the same program is running? I would like to put the programs version in the form.name property
: : : :
: : : : //Eagleman
: : : :
: : : :
: : :
: : :
: :
: :
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.