Attribute constructor has a 'ByRef' parameter of type '<typename>'; cannot use constructors with byref parameters to apply the attribute

An attribute is applied to a programming element using an attribute constructor that takes a ByRef parameter.

Attributes are applied at compile time, and the compiler needs concrete values to pass to the attribute constructor. A ByRef parameter takes a pointer to a value, which cannot be evaluated at compile time.

You can define an attribute constructor that takes a ByRef parameter, and you can use it for purposes such as inheriting, but when you apply the attribute you must use a constructor that does not take any ByRef parameters.

Error ID: BC36006

To correct this error

  • Apply the attribute using a constructor that does not take any ByRef parameters, or do not apply the attribute at all.

See Also

Concepts

Attributes Overview in Visual Basic

Application of Attributes

Passing Arguments by Value and by Reference

Reference

ByRef