'New' cannot be used on a type parameter that does not have a 'New' constraint

A declaration statement uses a New (Visual Basic) clause specifying a type parameter as the type to be created, and the type parameter is declared without a New constraint.

A constraint on a type parameter imposes a requirement on any type argument passed to that type parameter when the generic type is created. The New constraint specifies that the type argument must expose a parameterless constructor that the creating code can access. This is what allows a New clause in a declaration statement to create an instance of that type.

Error ID: BC32046

To correct this error

  • If you can require the type argument to expose an accessible parameterless constructor, add the New constraint to the declaration of the type parameter.

  • If you cannot require the type argument to expose an accessible parameterless constructor, remove the New clause from the declaration statement. You cannot guarantee that any type argument passed to that type parameter permits creation of an instance.

See Also

Concepts

Generic Types in Visual Basic

Reference

Type List