SYMPTOMS
A call to COleDispatchDriver::InvokeHelper causes the server to generate an
error when the return type is VT_EMPTY. The nature of the error depends on
the automation server. For example, the Word.Basic automation server causes
the following error on some methods that have a return type of void (_DEBUG
build):
Assertion Failed Line 315, OLEDISP2.CPP
By using the debugger to examine the excepInfo structure, you'll see that
the btrDescription member contains this message:
Non Function called as function.
RESOLUTION
To work around this problem, derive your own class from COleDispatchDriver,
such as CMyOleDispatchDriver, and create your own InvokeHelperVoid
function. Then call your own InvokeHelperVoid function instead of
InvokeHelper when you need to call a method that has no return value.
To implement this work around, create two new functions in your
COleDispatchDriver derived class:
CMyOleDispatchDriver::InvokeHelperVVoid
CMyOleDispatchDriver::InvokeHelperVoid
Implement these functions by copying the implementations of InvokeHelperV
and InvokeHelper from OLEDISP2.CPP.
Then modify the following line in InvokeHelperVoid from:
InvokeHelperV(dwDispID, wFlags, vtRet, pvRet, pbParamInfo,
argList);
InvokeHelperVVoid(dwDispID, wFlags, vtRet, pvRet, pbParamInfo,
argList);
Then modify the following lines in InvokeHelperVVoid from:
HRESULT hr = m_lpDispatch->Invoke(dwDispID, IID_NULL, 0, wFlags,
&dispparams, &vaResult, &excepInfo, &nArgErr);
HRESULT hr = m_lpDispatch->Invoke(dwDispID, IID_NULL, 0, wFlags,
&dispparams, NULL, &excepInfo, &nArgErr);
On some servers, you may also need to re-implement the
COleDispatchDriver::SetProperty function and replace it with your own
SetPropertyVoid function by copying the implementation from OLEDISP2.CPP.
Just as for the InvokeHelper function, you will need to change it to call
InvokeHelperVVoid instead of InvokeHelperV.