'<procedurename>' method for event '<eventname>' cannot be marked CLS compliant because its containing type '<typename>' is not CLS compliant

A custom event declares an AddHandler or RemoveHandler procedure and marks it as <CLSCompliant(True)>, but the event is defined in a type that is marked as <CLSCompliant(False)> or is not marked.

When you apply CLSCompliantAttribute to a programming element, you set the attribute's isCompliant parameter to either True or False to indicate compliance or noncompliance. There is no default for this parameter, and you must supply a value.

If you do not apply CLSCompliantAttribute to an element, it is considered to be noncompliant.

By default, this message is a warning. For information on hiding warnings or treating warnings as errors, see Configuring Warnings in Visual Basic.

Error ID: BC40053

To correct this error

  • If you require CLS compliance, define the event within a type that is CLS compliant.

  • If you require that the event remain within its containing type, remove CLSCompliantAttribute from its definition or mark it as <CLSCompliant(False)>.

See Also

Tasks

How to: Declare Events That Avoid Blocking

How to: Declare Events That Conserve Memory Use

Concepts

AddHandler and RemoveHandler

Writing CLS-Compliant Code