Getting Assembly Information

tymbow

Member
Joined
Dec 14, 2003
Messages
13
Im getting some attributes from the assembly and I cant seem to get the version attribute. When I use the following code it throws an out of bounds exception for the array as there are no elements.

The AssemblyVersion attribute is defined and this code works perfectly for every other assembly attribute. Any thoughts on this?

Code:
        Public ReadOnly Property Version() As String Implements IAssemblyInformation.Version

            Get

                 Get the version attribute

                Dim attrVersion As AssemblyVersionAttribute

                attrVersion = CType(myAssembly.GetCustomAttributes(GetType(AssemblyVersionAttribute), False)(0), AssemblyVersionAttribute)

                 Return the version string

                Return attrVersion.Version.ToCharArray

                 Clear any objects we used 

                attrVersion = Nothing

            End Get

        End Property
 
The correct way to get an assemblys version is not by reading an attribute, but by looking at the Assembly.GetName().Version property.
 
Back
Top