我创建了一个自定义属性并在 AssemblyInfo.vb 文件中使用它。该属性在另一个文件中声明,如下所示:
Public NotInheritable Class AssemblyBuildNameAttribute
Inherits Attribute
Private _p1 As String
Sub New(p1 As String)
' TODO: Complete member initialization
_p1 = p1
End Sub
End Class
并且在 AssemblyInfo.vb 文件中,如下所示:
<Assembly: AssemblyVersion("0.4.15")>
<Assembly: AssemblyFileVersion("13.10.1.8")>
<Assembly: AssemblyBuildName("alpha")>
我怎样才能调用这个自定义属性?我希望能够像这样调用版本信息一样调用它:
Public Class AppInfo
Public Shared Function VersionMajor() As String
Return Assembly.GetExecutingAssembly().GetName().Version.Major.ToString()
End Function
Public Shared Function VersionMinor() As String
Return Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString()
End Function
Public Shared Function VersionPatch() As String
Return Assembly.GetExecutingAssembly().GetName().Version.Build.ToString()
End Function
End Class