Microsoft KB Archive/297339

= BUG: ATLCOM.h Incorrectly Implements IDispEventSimplImpl Parameter Types =

Article ID: 297339

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Encarta Reference Suite 2001

-



This article was previously published under Q297339



SYMPTOMS
When you are running an application on Windows CE 3.0 that uses Active Template Library (ATL) to sink events from a COM object, it may present an exception when the event occurs. In some cases the symptom may not be an exception but rather data overflow in the event's parameters.



CAUSE
ATLCOM.h has code in IDispEventSimpleImpl that, when building the event argument list, will map the parameter types in the incorrect order if SINK_ENTRY_INFO was used to build the sink map.



RESOLUTION
To resolve this problem, you can change ATLCOM.h so that the Invoke member function of IDispSimpleImpl correctly maps the event parameter types when sink events is used. The correction can be made by replacing line 4159 pvars[i].vt = pInfo->pVarTypes[pInfo->nParams - i - 1]; with the following: pvars[i].vt = pFound->pInfo ? pInfo->pVarTypes[i] : pInfo->pVarTypes[pInfo->nParams - i - 1];



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



MORE INFORMATION
This problem becomes evident when a COM object exposes events through an IDispatch interface and when ATL's IDispEventSimpleImpl is used to create an event sink. Also, since order of parameter types is the issue, the problem is only evident when an event takes two or more parameters.

The exception mentioned in the &quot;Symptoms&quot; section will occur if one parameter of an event method is an integral value type, such as long, and another is a BSTR. In this case ATL will call VariantClear on a variant of type VT_BSTR but the value is not a string. OLEAUT32.dll will then fail in SysFreeString.

Keywords: kbbug kbfix KB297339

-

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

© Microsoft Corporation. All rights reserved.