Module.GetCustomAttributes returns all custom attributes.
Imports System
Imports System.Reflection
<Module: MySimpleAttribute("module-level")>
Class MyMainClass
Shared Sub Main()
Dim moduleArray() As [Module]
moduleArray = [Assembly].GetExecutingAssembly().GetModules(False)
Dim myModule As [Module] = moduleArray(0)
Dim attributes() As Object
attributes = myModule.GetCustomAttributes(True)
Dim o As [Object]
For Each o In attributes
Console.WriteLine("Found this attribute on myModule: {0}", o.ToString())
Next o
End Sub
End Class
<AttributeUsage(AttributeTargets.Class Or AttributeTargets.Module)> _
Public Class MySimpleAttribute
Inherits Attribute
Private name As String
Public Sub New(ByVal newName As String)
name = newName
End Sub
End Class
Related examples in the same category