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



The information in this article applies to:

  • Microsoft Office XP Developer
  • Microsoft Access 2002

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.

MORE INFORMATION

Steps to Reproduce Behavior

  1. On a computer with Office 2000 installed, start Visual C++ version 6.0 and create a new Win32 Console application. Name the project MSCalCrash.
  2. Add a new Visual C++ source file named Mscaltest.cpp to the project, and paste the following code in the code window:
    #include <windows.h>
    
    // Change the path to Mscal.ocx as needed.
    #import "D:/Program Files/Microsoft Office/Office/MSCAL.OCX" \ 
       no_implementation raw_interfaces_only raw_native_types named_guids
    
    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, "Today is %S", bstrDate);
                SysFreeString(bstrDate);
             }
             else lstrcpy(szbuf, "Can't get date, but test worked.");
             MessageBox(NULL, szbuf, "Success", MB_SETFOREGROUND);
          }
          else
          {
             wsprintf(szbuf, "You hit the error. hr = 0x%X", hr);
             MessageBox(NULL, szbuf, NULL, MB_SETFOREGROUND);
          }
    
          pcal->Release();
       }
       else
       {
          MessageBox(NULL, "Could not start MSCAL. Is Office installed?",
             NULL, MB_SETFOREGROUND);
       }
    
       CoUninitialize();
       return hr;
    }
    					
  3. Press F5 to compile and run the code. You should see a dialog box that contains the current date.
  4. 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.

Modification Type:MajorLast Reviewed:12/12/2003
Keywords:kbAutomation kbbug kbpending KB311219