| Previous | Next |
| DISP_E_NONAMEDARGS | DISP_E_EXCEPTION |
DISP_E_BADVARTYPE
Automation call contains an invalid VARIANT type
DISP_E_BADVARTYPE is HRESULT 2147614728 (0x80020008) from winerror.h. The documented description is “Bad variable type.” The value must be interpreted at VARIANTARG validation before or during IDispatch invocation.
A VARIANT has an unsupported, reserved, inconsistent, or malformed VARTYPE encoding.
Where the result appears
- This result is returned while Automation binds or executes VARIANTARG validation before or during IDispatch invocation.
Typical causes and interpretation
Common cause categories are: the VARIANT was not initialized; flags are combined illegally; the union field does not match vt; memory corruption changed the tag.
Key distinction: a VARIANT has an unsupported, reserved, inconsistent, or malformed VARTYPE encoding.
Evidence to preserve
- Record this result with the object CLSID or ProgID, interface identity, member DISPID, dispatch flags, and type-library version.
- Capture vt value; union field used; VT_BYREF and VT_ARRAY flags; initialization path; ownership and VariantClear result.
A useful diagnostic event contains ownership and shape information, not raw documents, passwords, access tokens, or full Automation values.
Correct handling and recovery
The appropriate recovery is to initialize with VariantInit, assign a supported VARTYPE and matching field, validate custom marshaling, and clear only owned values. Repeat the operation only after the failed condition has changed and the caller can distinguish a duplicate effect.
Use the documented output contract and reconcile remote or persistent effects before replaying the request.
Practical scenario
A native caller leaves stack garbage in vt before assigning a BSTR pointer; VariantInit removes the invalid type tag.
Difference from related HRESULTs
DISP_E_TYPEMISMATCH means a valid VARIANT cannot satisfy the parameter type; it means the VARIANT representation itself is invalid.
References
Looking for a different code? Search another status or error code.
