Assembly.IsDefined Method
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Indicates whether or not a specified attribute has been applied to the assembly.
Assembly: mscorlib (in mscorlib.dll)
'Declaration Public Overridable Function IsDefined ( _ attributeType As Type, _ inherit As Boolean _ ) As Boolean
Parameters
- attributeType
- Type: System.Type
The Type of the attribute to be checked for this assembly.
- inherit
- Type: System.Boolean
This argument is ignored for objects of this type.
Return Value
Type: System.Booleantrue if the attribute has been applied to the assembly; otherwise, false.
Implements
ICustomAttributeProvider.IsDefined(Type, Boolean)| Exception | Condition |
|---|---|
| ArgumentNullException | attributeType is Nothing. |
| ArgumentException | attributeType uses an invalid type. |
The following code example applies the AssemblyTitleAttribute attribute to an assembly and then uses IsDefined to indicate whether it was applied. It also tests an attribute that was not applied.
Imports System.Reflection ' Apply an assembly-level attribute. <Assembly: AssemblyTitleAttribute("My Cool Application")> Class Example Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) Dim thisAssembly As [Assembly] = [Assembly].GetExecutingAssembly() outputBlock.Text &= _ String.Format("IsDefined(AssemblyTitleAttribute) = {0}" & vbLf, _ thisAssembly.IsDefined(GetType(AssemblyTitleAttribute), False)) outputBlock.Text &= _ String.Format("IsDefined(AssemblyCompanyAttribute) = {0}" & vbLf, _ thisAssembly.IsDefined(GetType(AssemblyCompanyAttribute), False)) End Sub End Class ' This example produces output similar to the following: ' 'IsDefined(AssemblyTitleAttribute) = True 'IsDefined(AssemblyCompanyAttribute) = False
Show: