'function' : must be a COM interface to fire COM events
The event interface that you use to fire COM events must be a COM interface. Note that the #include lines of the ATL header files shown in the sample below are required for using COM events. To fix this error, make IEvents
(the eventing interface) a COM interface by applying one of the following attributes to the interface definition: object, dual, or dispinterface.
The following sample generates C3706:
#define _ATL_ATTRIBUTES 1 #include <atlbase.h> #include <atlcom.h> #include <atlctl.h> [module(dll, name=idid, uuid="12341234-1234-1234-1234-123412341234")]; // uncomment [object] //[object] __interface IEvents : IUnknown { HRESULT event1(/*[in]*/ int i); // uncomment [in] }; [dual] __interface IBase { HRESULT fireEvents(); }; [coclass, event_source(com)] class CEventSrc : public IBase { public: __event __interface IEvents; // C3706 HRESULT fireEvents() { HRESULT hr = IEvents_event1(123); return hr; } }; void main() { }