AssemblyVersionAttribute Doesn't Exist In Assembly

P

Phil Galey

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 AssemblyVersionAttribute object doesn't exist in the assembly. How can I make sure the AssemblyVersionAttribute will be present like the others? Thanks.

-----------------------------------------------------------------------------------------------
mAssy = Reflection.Assembly.GetCallingAssembly

Dim aTitleAttr As AssemblyTitleAttribute = _
AssemblyTitleAttribute.GetCustomAttribute( _
mAssy, GetType(AssemblyTitleAttribute))
Me.Text = "About " & aTitleAttr.Title
lblTitle.Text = aTitleAttr.Title
Dim aCopyRight As AssemblyCopyrightAttribute = _
AssemblyCopyrightAttribute.GetCustomAttribute( _
mAssy, GetType(AssemblyCopyrightAttribute))
lblCopyrightInfo.Text = aCopyRight.Copyright

Dim aDescription As AssemblyDescriptionAttribute = _
AssemblyDescriptionAttribute.GetCustomAttribute( _
mAssy, GetType(AssemblyDescriptionAttribute))
lblDescription.Text = aDescription.Description

Dim aVersion As AssemblyVersionAttribute = _
AssemblyVersionAttribute.GetCustomAttribute( _
mAssy, GetType(AssemblyVersionAttribute))
lblVersion.Text = aVersion.Version
---------------------------------------------------------------------------------------------
 
H

Herfried K. Wagner [MVP]

Phil Galey said:
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 AssemblyVersionAttribute object
doesn't exist in the assembly. How can I make sure the
AssemblyVersionAttribute will be present like the others?

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

Phil Galey

Herfried,

Yes. That's where I specified all the information, including the Version.
I'm currently feeding the Application.ProductVersion 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 AssemblyVersionAttribute in the intellisense with the other
AssemblyXAttributes.

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 AssemblyVersionAttribute.

Phil Galey
 
R

Richard Myers

Hi Phil

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

Private Sub PopulateAssemblySummary(ByVal objAssembly As [Assembly])
Dim nvcAttribs As Specialized.NameValueCollection
Dim objListViewItem As New System.Windows.Forms.ListViewItem
Dim strAssemblyName As String

nvcAttribs = AssemblyAttribs(objAssembly)
With objListViewItem
.Text = objAssembly.GetName.Name
.Tag = objAssembly.GetName.Name
strAssemblyName = .Text
If strAssemblyName = _strCallingAssemblyName Then
.Text &= " (calling)"
End If
If strAssemblyName = _strExecutingAssemblyName Then
.Text &= " (executing)"
End If
If strAssemblyName = _strEntryAssemblyName Then
.Text &= " (entry)"
End If
.SubItems.Add(AssemblyVersion(objAssembly))
.SubItems.Add(AssemblyBuildDateString(objAssembly, True))
.SubItems.Add(RemoveFileURI(AssemblyCodeBase(objAssembly)))
End With
lvwAssemblyInfo.Items.Add(objListViewItem)
cboAssemblyNames.Items.Add(strAssemblyName)
End Sub



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 AssemblyVersionAttribute object
doesn't exist in the assembly. How can I make sure the
AssemblyVersionAttribute will be present like the others? Thanks.

---------------------------------------------------------------------------
--------------------
mAssy = Reflection.Assembly.GetCallingAssembly

Dim aTitleAttr As AssemblyTitleAttribute = _
AssemblyTitleAttribute.GetCustomAttribute( _
mAssy, GetType(AssemblyTitleAttribute))
Me.Text = "About " & aTitleAttr.Title
lblTitle.Text = aTitleAttr.Title
Dim aCopyRight As AssemblyCopyrightAttribute = _
AssemblyCopyrightAttribute.GetCustomAttribute( _
mAssy, GetType(AssemblyCopyrightAttribute))
lblCopyrightInfo.Text = aCopyRight.Copyright
Dim aDescription As AssemblyDescriptionAttribute = _
AssemblyDescriptionAttribute.GetCustomAttribute( _
mAssy, GetType(AssemblyDescriptionAttribute))
lblDescription.Text = aDescription.Description
Dim aVersion As AssemblyVersionAttribute = _
AssemblyVersionAttribute.GetCustomAttribute( _
mAssy, GetType(AssemblyVersionAttribute))
lblVersion.Text = aVersion.Version
 
R

Richard Myers

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;

http://www.codeproject.com/vb/net/aboutbox.asp

Richard

Richard Myers said:
Hi Phil

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

Private Sub PopulateAssemblySummary(ByVal objAssembly As [Assembly])
Dim nvcAttribs As Specialized.NameValueCollection
Dim objListViewItem As New System.Windows.Forms.ListViewItem
Dim strAssemblyName As String

nvcAttribs = AssemblyAttribs(objAssembly)
With objListViewItem
.Text = objAssembly.GetName.Name
.Tag = objAssembly.GetName.Name
strAssemblyName = .Text
If strAssemblyName = _strCallingAssemblyName Then
.Text &= " (calling)"
End If
If strAssemblyName = _strExecutingAssemblyName Then
.Text &= " (executing)"
End If
If strAssemblyName = _strEntryAssemblyName Then
.Text &= " (entry)"
End If
.SubItems.Add(AssemblyVersion(objAssembly))
.SubItems.Add(AssemblyBuildDateString(objAssembly, True))
.SubItems.Add(RemoveFileURI(AssemblyCodeBase(objAssembly)))
End With
lvwAssemblyInfo.Items.Add(objListViewItem)
cboAssemblyNames.Items.Add(strAssemblyName)
End Sub



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 AssemblyVersionAttribute object
doesn't exist in the assembly. How can I make sure the
AssemblyVersionAttribute will be present like the others? Thanks.

------------------------------------------------------------------------- --
--------------------
mAssy = Reflection.Assembly.GetCallingAssembly

Dim aTitleAttr As AssemblyTitleAttribute = _
AssemblyTitleAttribute.GetCustomAttribute( _
mAssy, GetType(AssemblyTitleAttribute))
Me.Text = "About " & aTitleAttr.Title
lblTitle.Text = aTitleAttr.Title
Dim aCopyRight As AssemblyCopyrightAttribute = _
AssemblyCopyrightAttribute.GetCustomAttribute( _
mAssy, GetType(AssemblyCopyrightAttribute))
lblCopyrightInfo.Text = aCopyRight.Copyright
Dim aDescription As AssemblyDescriptionAttribute = _
AssemblyDescriptionAttribute.GetCustomAttribute( _
mAssy, GetType(AssemblyDescriptionAttribute))
lblDescription.Text = aDescription.Description
Dim aVersion As AssemblyVersionAttribute = _
AssemblyVersionAttribute.GetCustomAttribute( _
mAssy, GetType(AssemblyVersionAttribute))
lblVersion.Text = aVersion.Version
------------------------------------------------------------------------- --
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top