Introduction
This is just a simple class to retrieve assembly data from the current application using VB.NET. It will return each of the assembly variables as a string.
Background
It seems that most of the code snippets I could find elsewhere just simply did not work or had lots of complicated forms that I did not need.
This one you can just import and it is done.
Using the code
Copy and compile and that's about it, or just download my example and reference the DLL.
Imports SYR = System.Reflection
Public Class GetAssembly
Private assembType As System.Reflection.Assembly
Public Sub New()
assembType = System.Reflection.Assembly.GetExecutingAssembly
End Sub
Public ReadOnly Property TName() As String
Get
Return assembType.GetName.ToString()
End Get
End Property
Public ReadOnly Property TFullName() As String
Get
Return assembType.GetName.FullName.ToString()
End Get
End Property
Public ReadOnly Property CodeBase() As String
Get
Return assembType.CodeBase.ToString()
End Get
End Property
Public ReadOnly Property Copyright() As String
Get
Dim attype As Type = GetType(SYR.AssemblyCopyrightAttribute)
Dim atr() As Object = assembType.GetCustomAttributes(attype, False)
Dim ct As SYR.AssemblyCopyrightAttribute = _
CType(atr(0), SYR.AssemblyCopyrightAttribute)
Return ct.Copyright
End Get
End Property
Public ReadOnly Property Company() As String
Get
Dim attype As Type = GetType(SYR.AssemblyCompanyAttribute)
Dim atr() As Object = assembType.GetCustomAttributes(attype, False)
Dim ct As SYR.AssemblyCompanyAttribute = CType(atr(0), SYR.AssemblyCompanyAttribute)
Return ct.Company
End Get
End Property
Public ReadOnly Property Description() As String
Get
Dim attype As Type = GetType(SYR.AssemblyDescriptionAttribute)
Dim atr() As Object = assembType.GetCustomAttributes(attype, False)
Dim da As SYR.AssemblyDescriptionAttribute = _
CType(atr(0), SYR.AssemblyDescriptionAttribute)
Return da.Description
End Get
End Property
Public ReadOnly Property Product() As String
Get
Dim attype As Type = GetType(SYR.AssemblyProductAttribute)
Dim atr() As Object = assembType.GetCustomAttributes(attype, False)
Dim pt As SYR.AssemblyProductAttribute = _
CType(atr(0), SYR.AssemblyProductAttribute)
Return pt.Product
End Get
End Property
Public ReadOnly Property Title() As String
Get
Dim attype As Type = GetType(SYR.AssemblyTitleAttribute)
Dim atr() As Object = assembType.GetCustomAttributes(attype, False)
Dim ta As SYR.AssemblyTitleAttribute = CType(atr(0), SYR.AssemblyTitleAttribute)
Return ta.Title
End Get
End Property
Public ReadOnly Property Version() As String
Get
Return assembType.GetName.Version.ToString()
End Get
End Property
End Class
History
- Version 1.0: No changes yet.