Indirect constraint '<constraint1>' obtained from the type parameter constraint '<typeparameter1>' conflicts with the constraint '<constraint2>'

A generic type is declared with conflicting constraints due to a combination of direct and indirect constraints.

The following statement can generate this error.

Public Class testClass(Of t1 As {t2, Class}, t2 As Structure)

The indirect constraint Structure and the direct constraint Class cause a conflict for type parameter t1, because the Structure constraint requires that the corresponding type argument be a value type, while Class requires that it be a reference type.

Error ID: BC32111

To correct this error

  • Change the type parameter constraints to avoid conflicting constraints.

See Also

Concepts

Generic Types in Visual Basic

Value Types and Reference Types

Reference

Type List

Structure (Visual Basic)

Class (Visual Basic)