You have to use Reflection to get attribute information and value, and you will need one proc for each attribute.
First though, your sample Attribute class is missing a key item: HOW TO RETURN the info. You need to add a property getter:
Friend ReadOnly GetBuild() As String
Get
Return _p1
End Get
End Property
NOW you are ready
Friend Function GetAsmBuild() As String
Dim assy As [Assembly] = [Assembly].GetExecutingAssembly
Dim Attributes As Object()
Attributes = assy.GetCustomAttributes(GetType(AssemblyBuildNameAttribute), False)
If Attributes.Length > 0 Then
Return Attributes(0).GetBuild
Else
Return String.Empty
End If
End Function
GetVersion
is the name of the Property getter. So for the one I added it would be:
Return Attributes(0).GetBuild
It is about the same as getting Attr for Classes or Enums etc. Also: Assemblies already have a version and such you can control in the Project properties settings. And procs already exist in System.Reflection
to return them.
Edit:
The way to get the info at runtime:
Public Shared Function VersionPatch() As String
Return GetAsmBuild
End Function
or name my proc VersionPatch