|
|
Title | Get information about the program's title, description, copyright, version, etc. in VB .NET |
Keywords | title, description, version, copyright, trademark, company, VB.NET |
Categories | VB.NET, Software Engineering |
|
|
Set these values in the attributes in the AssemblyInfo.vb file.
|
|
<Assembly: AssemblyTitle("Version Example Assembly")>
<Assembly: AssemblyDescription("This assembly demonstrates " & _
"getting a program's version information")>
<Assembly: AssemblyCompany("Rocky Mountain Computer " & _
"Consulting, Inc.")>
<Assembly: AssemblyProduct("Version Example Product")>
<Assembly: AssemblyCopyright("Copyright 2004, Rocky " & _
"Mountain Computer Consulting, Inc.")>
<Assembly: AssemblyTrademark("(generic trademark)")>
<Assembly: CLSCompliant(True)>
...
<Assembly: AssemblyVersion("1.2.3.4")>
|
|
Create an Assembly object from the executing assembly. Use the Assembly's GetCustomAttribute method to get the atribute you want and then cast it into its correct attribute type. Use its properties to get the corresponding value. (Yes, this is a lot more complicated than it probably should be.)
|
|
Imports System.Reflection
Private m_MyAssembly As [Assembly]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
m_MyAssembly = [Assembly].GetExecutingAssembly()
txtTitle.Text = GetAssemblyTitle()
...
End Sub
' Return the assembly's Title attribute value.
Private Function GetAssemblyTitle() As String
If m_MyAssembly.IsDefined(GetType(AssemblyTitleAttribute), _
True) Then
Dim attr As Attribute = _
Attribute.GetCustomAttribute(m_MyAssembly, _
GetType(AssemblyTitleAttribute))
Dim title_attr As AssemblyTitleAttribute = _
DirectCast(attr, AssemblyTitleAttribute)
Return title_attr.Title
Else
Return ""
End If
End Function
...
|
|
|
|
|
|