Expression of type '<typename>' cannot be converted to 'Object' or 'ValueType'

An expression evaluates to a type that cannot be boxed by the common language runtime (CLR).

Boxing refers to the processing necessary to convert a type to Object or, on occasion, to ValueType. The common language runtime cannot box certain types, for example ArgIterator and TypedReference.

If you have not used CType or CObj in the statement containing this expression, Visual Basic has attempted an implicit conversion that causes this error.

Error ID: BC31394

To correct this error

  1. Locate the expression that evaluates to the cited type.

  2. Locate the part of your statement that attempts to box the cited type.

  3. Rewrite the statement to avoid the boxing conversion.

See Also

Concepts

Implicit and Explicit Conversions