Returning Errors
A version of this page is also available for
4/8/2010
IDispatch::Invoke returns DISP_E_MEMBERNOTFOUND if one of the following conditions occurs:
- A member or parameter with the specified DISPID and matching cArgs cannot be found*,* and the parameter is not optional.
- The member is a void function, and the caller did not set pVarResult to NULL.
- The member is a read-only property, and the caller set wFlags to DISPATCH_PROPERTYPUT or DISPATCH_PROPERTYPUTREF.
If Invoke finds the member, but uncovers errors in the parameter list, it returns one of several other errors. DISP_E_BAD_PARAMCOUNT means that the DISPPARAMS structure contains an incorrect number of parameters for the property or method. DISP_E_NONAMEDARGS means that Invoke received named parameters, but they are not supported by the member.
DISP_E_PARAMNOTFOUND means that the correct number of parameters was passed, but the DISPID for one or more parameters was incorrect. If Invoke cannot convert one of the parameters to the desired type, it returns DISP_E_TYPEMISMATCH.
In these two cases, if it can identify which parameter is incorrect, Invoke sets *puArgErr to the index within rgvarg of the parameter with the error. For example, if an Automation method expects a reference to a double-precision number as a parameter, but receives a reference to an integer, the parameter is coerced.
However, if the method receives a date, Invoke returns DISP_E_TYPEMISMATCH and sets *puArgErr to the index of the integer in the parameter array.
Automation provides functions to perform standard conversions of VARIANT, and these functions should be used for consistent operation. DISP_E_TYPEMISMATCH is returned only when these functions fail.
See Also
Reference
DISPPARAMS
IDispatch::Invoke
VARIANT and VARIANTARG