Assembly: version

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Russ Green

    #1

    Assembly: version

    I'm trying to retrieve the version attribute of the current assembly in
    Console and Service applications. I've tried the following method but it
    doesn't work for me. Any ideas:

    ' Return the assembly's Version attribute value.
    Public Function GetAssemblyVers ion() As String
    Dim m_MyAssembly As [Assembly] = [Assembly].GetExecutingAs sembly

    If m_MyAssembly.Is Defined(GetType (AssemblyVersio nAttribute), True) Then
    Dim attr As Attribute = _
    Attribute.GetCu stomAttribute(m _MyAssembly,
    GetType(Assembl yVersionAttribu te))
    Dim version_attr As AssemblyVersion Attribute = DirectCast(attr ,
    AssemblyVersion Attribute)
    Return version_attr.Ve rsion.ToString
    Else
    Return ""
    End If
    End Function


    TIA

    Russ
  • Ben Eaton

    #2
    Re: Assembly: version

    Try this:

    Dim objAssembly As System.Reflecti on.Assembly =
    System.Reflecti on.Assembly.Get ExecutingAssemb ly
    Dim objVersion As Version = objAssembly.Get Name.Version

    System.Diagnost ics.Debug.Write Line(objVersion .ToString)

    hth

    ~Ben

    "Russ Green" <mail-NO@SPAM-russgreen.com> wrote in message
    news:ew1taKfaFH A.3272@TK2MSFTN GP10.phx.gbl...[color=blue]
    > I'm trying to retrieve the version attribute of the current assembly in
    > Console and Service applications. I've tried the following method but it
    > doesn't work for me. Any ideas:
    >
    > ' Return the assembly's Version attribute value.
    > Public Function GetAssemblyVers ion() As String
    > Dim m_MyAssembly As [Assembly] = [Assembly].GetExecutingAs sembly
    >
    > If m_MyAssembly.Is Defined(GetType (AssemblyVersio nAttribute), True) Then
    > Dim attr As Attribute = _
    > Attribute.GetCu stomAttribute(m _MyAssembly,
    > GetType(Assembl yVersionAttribu te))
    > Dim version_attr As AssemblyVersion Attribute = DirectCast(attr ,
    > AssemblyVersion Attribute)
    > Return version_attr.Ve rsion.ToString
    > Else
    > Return ""
    > End If
    > End Function
    >
    >
    > TIA
    >
    > Russ[/color]


    Comment

    Working...