BUG: An ATL event does not fire when the event is defined with an interface alias in Visual C++ 6.0 (244204)



The information in this article applies to:

  • The Microsoft Active Template Library (ATL) 3.0, when used with:
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0

This article was previously published under Q244204

SYMPTOMS

When using IDispEventImpl to sink events in an ATL container, the event does not fire and the IDispatch::Invoke call to fire the event returns S_OK. The event actually fails in the call to ITypeInfo2::GetFuncIndexOfMemId with an HRESULT of 0x8002802B within IDispEventSimpleImpl::Invoke.

CAUSE

A dispinterface may be defined by explicitly listing the set of supported methods and properties or by listing a single interface. Both methods are shown here.
[
    [attributes]
]
dispinterface dispinterface-name
{
    properties:
        property-list
    methods:
        method-list
};

[
    [attributes]
]
dispinterface dispinterface-name
{
    interface interface-name
};
				
The symptoms described occur if the event interface that the container is trying to provide a sink for is defined by listing a single interface.

RESOLUTION

Define the event interface, that uses IDispEventImpl to sink events, by listing the individual properties and methods, or derive the sink object from IDispEventSimpleImpl instead of IDispEventImpl.

For more information about how to use IDispEventSimpleImpl, click the following article number to view the article in the Microsoft Knowledge Base:

194179 AtlEvnt.exe sample shows how to create ATL sinks by using the ATL IDispEventImpl and IDispEventSimpleImpl classes

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the behavior

The following steps require modification to files provided by the ATLEvnt sample that is described in the following Microsoft Knowledge Base article:

194179 AtlEvnt.exe sample shows how to create ATL sinks by using the ATL IDispEventImpl and IDispEventSimpleImpl classes

  1. Open the EventSrc.idl file and change the definition so it looks like this.
    // EventSrc.idl : IDL source for EventSrc.dll
    // 
    
    // This file will be processed by the MIDL tool to
    // produce the type library (EventSrc.tlb) and marshalling code.
    
    import "oaidl.idl";
    import "ocidl.idl";
    	[
    		object,
    		uuid(476D8D1B-381B-11D2-A610-00AA00C14AF9),
    		dual,
    		helpstring("ISrcObj Interface"),
    		pointer_default(unique)
    	]
    	interface ISrcObj : IDispatch
    	{
    	};
    
    [
    	uuid(476D8D0F-381B-11D2-A610-00AA00C14AF9),
    	version(1.0),
    	helpstring("EventSrc 1.0 Type Library")
    ]
    library EVENTSRCLib
    {
    	importlib("stdole32.tlb");
    	importlib("stdole2.tlb");
    	
    	[
    		object,
    		uuid(ADF41C66-7795-11d3-9045-0008C76BD9D2),
    		oleautomation,
    		helpstring("_IMyEvents Interface"),
    		pointer_default(unique)
    	]
    	interface _IMyEvents : IUnknown
    	{
    		[id(1), helpstring("method Tick")] HRESULT Tick([in] long tckcnt);
    	}; 
    	[
    		uuid(7F3F60C1-381E-11d2-A610-00AA00C14AF9)
    	]
    
    	dispinterface _EventSink
    	{
    		interface _IMyEvents;
    /*		properties:
    		methods:
    		[id(1), helpstring("method Tick")] HRESULT Tick([in] long tckcnt);
    */ 
    	}
    
    	[
    		uuid(476D8D1C-381B-11D2-A610-00AA00C14AF9),
    		helpstring("SrcObj Class")
    	]
    	coclass SrcObj
    	{
    		[default] interface ISrcObj;
    		[default, source] dispinterface _EventSink;
    	};
    };
    						
  2. Rebuild the EventSrc object.
  3. Set ATLEvnt as the active project and rebuild the ATLEvnt.exe file.
  4. Run ATLEvnt.Exe, and click the buttons to connect to each sink. Notice that the two event sinks (CSinkObj and CSinkObj2) that derive from IDispEventImpl are not get fired correctly. However, the two event sinks (CSinkObj3 and CSinkObj4) that derive from IDispEventSimpleImpl are fired correctly.

Modification Type:MajorLast Reviewed:9/30/2005
Keywords:kbtshoot kbActivexEvents kbBug kbIDL KB244204 kbAudDeveloper