Microsoft KB Archive/311219

= BUG: Office XP Version of Mscal.ocx Breaks Binary Compatibility For Early Bound Clients =

Article ID: 311219

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Office XP Developer Edition
 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q311219



SYMPTOMS
Clients that use early binding to the Microsoft Calendar control (Mscal.ocx) may encounter unexpected errors or invalid data or may crash because of stack corruption when the properties or methods of the control's ICalendar interface are called. The problem occurs on computers that have recently had Office XP installed.



CAUSE
Version 10.0 of the Calendar control, which ships with Office XP, contains added methods to support assigning Font objects by reference (putref) for the following properties:
 * DayFont
 * GridFont
 * TitleFont

Because of this change, methods are added to the middle of the interface, thereby breaking binary compatibility by changing the layout of the ICalendar v-table. Consequently, any client that is built by using early binding to the 8.0 (Office 97) or 8.1 (Office 2000) version of Mscal.ocx may call the wrong v-table methods on the 10.0 version.



RESOLUTION
All clients that use Mscal.ocx should use late (DISPID) binding to call methods on the ICalendar interface.

Microsoft Visual Basic (VB), Visual Basic for Applications (VBA), and MFC control containers are not normally affected by this problem because they use late (DISPID) binding by default. Active Template Library (ATL) control containers that use #import are more likely to encounter the problem, and can use CComDispatchDriver to wrap the control to make late-bound calls.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 On a computer with Office 2000 installed, start Visual C++ version 6.0 and create a new Win32 Console application. Name the project MSCalCrash.  Add a new Visual C++ source file named Mscaltest.cpp to the project, and paste the following code in the code window:
 * 1) include 

// Change the path to Mscal.ocx as needed. no_implementation raw_interfaces_only raw_native_types named_guids
 * 1) import &quot;D:/Program Files/Microsoft Office/Office/MSCAL.OCX&quot; \

int main {  HRESULT hr; MSACAL::ICalendar *pcal; VARIANT vtValue; BSTR bstrDate; CHAR szbuf[512];

if (FAILED(hr = CoInitialize(NULL))) return hr;

hr = CoCreateInstance(MSACAL::CLSID_Calendar,     NULL, CLSCTX_INPROC_SERVER, MSACAL::IID_ICalendar, (void**)&pcal);

if (SUCCEEDED(hr)) {     hr = pcal->get_Value(&vtValue); if (SUCCEEDED(hr)) {        if (SUCCEEDED(VarBstrFromDate(vtValue.date, 0,            LOCALE_NOUSEROVERRIDE, &bstrDate))) {           wsprintf(szbuf, &quot;Today is %S&quot;, bstrDate); SysFreeString(bstrDate); }        else lstrcpy(szbuf, &quot;Can't get date, but test worked.&quot;); MessageBox(NULL, szbuf, &quot;Success&quot;, MB_SETFOREGROUND); }     else {        wsprintf(szbuf, &quot;You hit the error. hr = 0x%X&quot;, hr); MessageBox(NULL, szbuf, NULL, MB_SETFOREGROUND); }

pcal->Release; }  else {     MessageBox(NULL, &quot;Could not start MSCAL. Is Office installed?&quot;,         NULL, MB_SETFOREGROUND); }

CoUninitialize; return hr; }                    Press F5 to compile and run the code. You should see a dialog box that contains the current date. Copy the .exe file to a computer with Office XP installed. You receive a dialog box that indicates a catastrophic failure (hr = 0x8000FFFF, E_UNEXPECTED).NOTE: This is just one type of error message. Other methods may generate different error messages, or may appear to work but display the wrong data.</ol>

Keywords: kbautomation kbbug kbpending KB311219

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.