Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The custom-designed version of 'System.Runtime.CompilerServices.ExtensionAttribute' found by the compiler is not valid. Its attribute usage flags must be set to allow assemblies, classes, and methods.
The custom-designed version of System.Runtime.CompilerServices.ExtensionAttribute that the compiler found does not set its attribute usage flags to enable application of the attribute to assemblies, methods, and classes. Application to at least those three program elements is required.
Error ID: BC36558
To correct this error
Change the attribute definition to enable the attribute to apply at least to assemblies, methods, and classes, as shown in the following examples.
Use System.Runtime.CompilerServices.ExtensionAttribute instead of the custom-designed version.
Example
The following example uses the AttributeUsage attribute to specify which program elements the new version of ExtensionAttribute can apply to. The example specifies three members of the AttributeTargets enumeration: Assembly, Class, and Method. The omission of any one of these elements will cause this error.
Namespace System.Runtime.CompilerServices
<AttributeUsage(AttributeTargets.Assembly Or _
AttributeTargets.Class Or AttributeTargets.Method)>
Class ExtensionAttribute
Inherits System.Attribute
' Definitions of methods, fields, and properties.
End Class
End Namespace
Alternatively, you could allow ExtensionAttribute to apply to all program elements by using the All member of AttributeTargets.
<AttributeUsage(AttributeTargets.All)>
Deleting the AttributeUsage line, as shown in the following code, produces the same result.
Namespace System.Runtime.CompilerServices
Class ExtensionAttribute
Inherits System.Attribute
' Definitions of methods, fields, and properties.
End Class
End Namespace
See Also
Tasks
How to: Define Your Own Attributes
Concepts
Attributes Overview in Visual Basic
Extension Methods (Visual Basic)