AssemblyVersionAttribute Doesn't Exist In Assembly

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Galey

    AssemblyVersionAttribute Doesn't Exist In Assembly

    I created an About box and am able to get all the assembly information from the program to show up in the About box except the Version.

    I created the About box as a separate Windows application, changed the Output to Class Library, and compile it as a DLL. I then reference it from my program. In the About Box form's Public Sub New routine, I placed the following code, where I'm getting all the assembly attributes from the calling assembly. The problem is all attributes are coming in fine, except the Version attribute. For some reason the AssemblyVersion Attribute object doesn't exist in the assembly. How can I make sure the AssemblyVersion Attribute will be present like the others? Thanks.

    -----------------------------------------------------------------------------------------------
    mAssy = Reflection.Asse mbly.GetCalling Assembly

    Dim aTitleAttr As AssemblyTitleAt tribute = _
    AssemblyTitleAt tribute.GetCust omAttribute( _
    mAssy, GetType(Assembl yTitleAttribute ))
    Me.Text = "About " & aTitleAttr.Titl e
    lblTitle.Text = aTitleAttr.Titl e
    Dim aCopyRight As AssemblyCopyrig htAttribute = _
    AssemblyCopyrig htAttribute.Get CustomAttribute ( _
    mAssy, GetType(Assembl yCopyrightAttri bute))
    lblCopyrightInf o.Text = aCopyRight.Copy right

    Dim aDescription As AssemblyDescrip tionAttribute = _
    AssemblyDescrip tionAttribute.G etCustomAttribu te( _
    mAssy, GetType(Assembl yDescriptionAtt ribute))
    lblDescription. Text = aDescription.De scription

    Dim aVersion As AssemblyVersion Attribute = _
    AssemblyVersion Attribute.GetCu stomAttribute( _
    mAssy, GetType(Assembl yVersionAttribu te))
    lblVersion.Text = aVersion.Versio n
    ---------------------------------------------------------------------------------------------


  • Herfried K. Wagner [MVP]

    #2
    Re: AssemblyVersion Attribute Doesn't Exist In Assembly

    "Phil Galey" <pagaley@starca lif.com.nospam> schrieb:[color=blue]
    >I created the About box as a separate Windows application, changed the
    >Output to Class Library, and compile it as a DLL. I then reference it from
    >my program. In the About Box form's Public Sub New routine, I placed the
    >following code, where I'm getting all the assembly attributes from the
    >calling assembly. The problem is all attributes are coming in fine, except
    >the Version attribute. For some reason the AssemblyVersion Attribute object
    >doesn't exist in the assembly. How can I make sure the
    >AssemblyVersio nAttribute will be present like the others?[/color]

    Did you already check the project's "AssemblyInfo.v b" file for the assembly
    version attribute?

    --
    Herfried K. Wagner [MVP]
    <URL:http://dotnet.mvps.org/>


    Comment

    • Phil Galey

      #3
      Re: AssemblyVersion Attribute Doesn't Exist In Assembly

      Herfried,

      Yes. That's where I specified all the information, including the Version.
      I'm currently feeding the Application.Pro ductVersion to the About Box
      less-elegantly as a parameter. The Version is available in that way, but
      I'd like to include all the information for the About box in the assembly
      object, which is supposed to contain the Version info, as indicated by the
      existence of the AssemblyVersion Attribute in the intellisense with the other
      AssemblyXAttrib utes.

      I was thinking that it might have something to do with the fact that the
      version is set up in four parts, perhaps requiring you to do an additional
      step to create the AssemblyVersion Attribute.

      Phil Galey


      "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
      news:eab9GMJ4EH A.924@TK2MSFTNG P14.phx.gbl...[color=blue]
      > "Phil Galey" <pagaley@starca lif.com.nospam> schrieb:[color=green]
      > >I created the About box as a separate Windows application, changed the
      > >Output to Class Library, and compile it as a DLL. I then reference it[/color][/color]
      from[color=blue][color=green]
      > >my program. In the About Box form's Public Sub New routine, I placed the
      > >following code, where I'm getting all the assembly attributes from the
      > >calling assembly. The problem is all attributes are coming in fine,[/color][/color]
      except[color=blue][color=green]
      > >the Version attribute. For some reason the AssemblyVersion Attribute[/color][/color]
      object[color=blue][color=green]
      > >doesn't exist in the assembly. How can I make sure the
      > >AssemblyVersio nAttribute will be present like the others?[/color]
      >
      > Did you already check the project's "AssemblyInfo.v b" file for the[/color]
      assembly[color=blue]
      > version attribute?
      >
      > --
      > Herfried K. Wagner [MVP]
      > <URL:http://dotnet.mvps.org/>
      >
      >[/color]


      Comment

      • Richard Myers

        #4
        Re: AssemblyVersion Attribute Doesn't Exist In Assembly

        Hi Phil

        I just ripped this function from an existing project. hth Richard

        Private Sub PopulateAssembl ySummary(ByVal objAssembly As [Assembly])
        Dim nvcAttribs As Specialized.Nam eValueCollectio n
        Dim objListViewItem As New System.Windows. Forms.ListViewI tem
        Dim strAssemblyName As String

        nvcAttribs = AssemblyAttribs (objAssembly)
        With objListViewItem
        .Text = objAssembly.Get Name.Name
        .Tag = objAssembly.Get Name.Name
        strAssemblyName = .Text
        If strAssemblyName = _strCallingAsse mblyName Then
        .Text &= " (calling)"
        End If
        If strAssemblyName = _strExecutingAs semblyName Then
        .Text &= " (executing)"
        End If
        If strAssemblyName = _strEntryAssemb lyName Then
        .Text &= " (entry)"
        End If
        .SubItems.Add(A ssemblyVersion( objAssembly))
        .SubItems.Add(A ssemblyBuildDat eString(objAsse mbly, True))
        .SubItems.Add(R emoveFileURI(As semblyCodeBase( objAssembly)))
        End With
        lvwAssemblyInfo .Items.Add(objL istViewItem)
        cboAssemblyName s.Items.Add(str AssemblyName)
        End Sub



        "Phil Galey" <pagaley@starca lif.com.nospam> wrote in message
        news:%23%23oW4F J4EHA.1452@TK2M SFTNGP11.phx.gb l...
        I created an About box and am able to get all the assembly information from
        the program to show up in the About box except the Version.

        I created the About box as a separate Windows application, changed the
        Output to Class Library, and compile it as a DLL. I then reference it from
        my program. In the About Box form's Public Sub New routine, I placed the
        following code, where I'm getting all the assembly attributes from the
        calling assembly. The problem is all attributes are coming in fine, except
        the Version attribute. For some reason the AssemblyVersion Attribute object
        doesn't exist in the assembly. How can I make sure the
        AssemblyVersion Attribute will be present like the others? Thanks.

        ---------------------------------------------------------------------------
        --------------------
        mAssy = Reflection.Asse mbly.GetCalling Assembly

        Dim aTitleAttr As AssemblyTitleAt tribute = _
        AssemblyTitleAt tribute.GetCust omAttribute( _
        mAssy, GetType(Assembl yTitleAttribute ))
        Me.Text = "About " & aTitleAttr.Titl e
        lblTitle.Text = aTitleAttr.Titl e
        Dim aCopyRight As AssemblyCopyrig htAttribute = _
        AssemblyCopyrig htAttribute.Get CustomAttribute ( _
        mAssy, GetType(Assembl yCopyrightAttri bute))
        lblCopyrightInf o.Text = aCopyRight.Copy right
        Dim aDescription As AssemblyDescrip tionAttribute = _
        AssemblyDescrip tionAttribute.G etCustomAttribu te( _
        mAssy, GetType(Assembl yDescriptionAtt ribute))
        lblDescription. Text = aDescription.De scription
        Dim aVersion As AssemblyVersion Attribute = _
        AssemblyVersion Attribute.GetCu stomAttribute( _
        mAssy, GetType(Assembl yVersionAttribu te))
        lblVersion.Text = aVersion.Versio n
        ---------------------------------------------------------------------------
        ------------------


        Comment

        • Richard Myers

          #5
          Re: AssemblyVersion Attribute Doesn't Exist In Assembly

          Sorry, that was a crap post by me. Told you nothing.
          This code i ripped from a Code Project article. Ive used it but given it
          was "sand boxed" didn't really bother to look into.
          The function i posted, actually calls other functions...doh !

          Here is the Url to original article;



          Richard

          "Richard Myers" <fake@address.c om> wrote in message
          news:%23KrZX$N4 EHA.3596@TK2MSF TNGP12.phx.gbl. ..[color=blue]
          > Hi Phil
          >
          > I just ripped this function from an existing project. hth Richard
          >
          > Private Sub PopulateAssembl ySummary(ByVal objAssembly As [Assembly])
          > Dim nvcAttribs As Specialized.Nam eValueCollectio n
          > Dim objListViewItem As New System.Windows. Forms.ListViewI tem
          > Dim strAssemblyName As String
          >
          > nvcAttribs = AssemblyAttribs (objAssembly)
          > With objListViewItem
          > .Text = objAssembly.Get Name.Name
          > .Tag = objAssembly.Get Name.Name
          > strAssemblyName = .Text
          > If strAssemblyName = _strCallingAsse mblyName Then
          > .Text &= " (calling)"
          > End If
          > If strAssemblyName = _strExecutingAs semblyName Then
          > .Text &= " (executing)"
          > End If
          > If strAssemblyName = _strEntryAssemb lyName Then
          > .Text &= " (entry)"
          > End If
          > .SubItems.Add(A ssemblyVersion( objAssembly))
          > .SubItems.Add(A ssemblyBuildDat eString(objAsse mbly, True))
          > .SubItems.Add(R emoveFileURI(As semblyCodeBase( objAssembly)))
          > End With
          > lvwAssemblyInfo .Items.Add(objL istViewItem)
          > cboAssemblyName s.Items.Add(str AssemblyName)
          > End Sub
          >
          >
          >
          > "Phil Galey" <pagaley@starca lif.com.nospam> wrote in message
          > news:%23%23oW4F J4EHA.1452@TK2M SFTNGP11.phx.gb l...
          > I created an About box and am able to get all the assembly information[/color]
          from[color=blue]
          > the program to show up in the About box except the Version.
          >
          > I created the About box as a separate Windows application, changed the
          > Output to Class Library, and compile it as a DLL. I then reference it[/color]
          from[color=blue]
          > my program. In the About Box form's Public Sub New routine, I placed the
          > following code, where I'm getting all the assembly attributes from the
          > calling assembly. The problem is all attributes are coming in fine,[/color]
          except[color=blue]
          > the Version attribute. For some reason the AssemblyVersion Attribute[/color]
          object[color=blue]
          > doesn't exist in the assembly. How can I make sure the
          > AssemblyVersion Attribute will be present like the others? Thanks.
          >
          > -------------------------------------------------------------------------[/color]
          --[color=blue]
          > --------------------
          > mAssy = Reflection.Asse mbly.GetCalling Assembly
          >
          > Dim aTitleAttr As AssemblyTitleAt tribute = _
          > AssemblyTitleAt tribute.GetCust omAttribute( _
          > mAssy, GetType(Assembl yTitleAttribute ))
          > Me.Text = "About " & aTitleAttr.Titl e
          > lblTitle.Text = aTitleAttr.Titl e
          > Dim aCopyRight As AssemblyCopyrig htAttribute = _
          > AssemblyCopyrig htAttribute.Get CustomAttribute ( _
          > mAssy, GetType(Assembl yCopyrightAttri bute))
          > lblCopyrightInf o.Text = aCopyRight.Copy right
          > Dim aDescription As AssemblyDescrip tionAttribute = _
          > AssemblyDescrip tionAttribute.G etCustomAttribu te( _
          > mAssy, GetType(Assembl yDescriptionAtt ribute))
          > lblDescription. Text = aDescription.De scription
          > Dim aVersion As AssemblyVersion Attribute = _
          > AssemblyVersion Attribute.GetCu stomAttribute( _
          > mAssy, GetType(Assembl yVersionAttribu te))
          > lblVersion.Text = aVersion.Versio n
          > -------------------------------------------------------------------------[/color]
          --[color=blue]
          > ------------------
          >
          >[/color]


          Comment

          Working...