PRB: "ASSERTION FAILED" with Excel 5.0 Automation ClassesID: Q114372
|
When calling methods of Automation objects for Microsoft Excel 5.0, you may receive the following message:
ASSERTION FAILED oledisp2.cpp, line 352!
ClassWizard creates the COleDispatchDriver-derived classes for use with Excel 5.0 by reading the Excel type library, XLEN50.OLB. The information in that type library states that some parameters passed to, and return values received from IDispatch::Invoke are of type VARIANT. These VARIANTs are unions of several data types with a VARTYPE member specifying the actual contained data. MFC 2.5 source file OLEDISP2.CPP contains the following code at line 352:
ASSERT(vtRet == vaResult.vt);
The intent of this ASSERT is to ensure strong type checking of arguments
used in IDispatch::Invoke calls to the Automation server. There are several
solutions:
// Machine generated IDispatch driver class(es) created with
// ClassWizard.
// This is the function generated by ClassWizard
VARIANT Worksheet::Application()
{
VARIANT result;
InvokeHelper(0x94,DISPATCH_METHOD,VT_VARIANT,(void*)&result,NULL);
return result;
}
// This is the same function with change #1
LPDISPATCH Worksheet::Application()
{
LPDISPATCH lpDispatch;
InvokeHelper(0x94, DISPATCH_METHOD, VT_DISPATCH,
(void*)&lpDispatch, NULL);
return lpDispatch;
}
// This is the same function with change #2
VARIANT Worksheet::Application()
{
VARIANT result;
InvokeHelper(0x94,DISPATCH_METHOD,VT_VARIANT,(void*)&result,NULL);
ASSERT(result.vt == VT_DISPATCH);
return result.;
}
Additional query words: 1.50 2.50 automation displatch ole oledisp2
Keywords : kb16bitonly
Version :
Platform :
Issue type :
Last Reviewed: July 20, 1999