By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,718 Members | 1,205 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,718 IT Pros & Developers. It's quick & easy.

Event sink causing access violation

P: n/a
I have created an event sink in my ATL COM project. The event sink receives
events from a C# component. There is no problem with receving events but
when my COM object is released I get an access violation - (MSCORWKS.DLL):
0xC0000005: Access Violation.

Here's my event sink class:

static const int EVENT_ID = 111;//any arbitary value

static const int DISPID_UPDATE_PROGRESS = 1;//disp id of UpdateProgress...

_ATL_FUNC_INFO OnUpdateProgressInfo =
CC_STDCALL, //calling conv...
VT_EMPTY,//return value...
1 ,//number of arguments...
{ VT_I4}//argument types...


class CEventSink : public
IDispEventSimpleImpl<EVENT_ID,CEventSink,&DIID_ITr ansferModuleEvent>
virtual ~CEventSink();
CConsumerAccess* m_pParent;
inline void SetParent(CConsumerAccess* pParent= NULL) { m_pParent =
pParent; }
void __stdcall OnUpdateProgress( long lResult);



I attach and detach the event sink in my COM object code in the following

void CConsumerAccess::EnsureEventSinkAttached()
if(m_pSinkClass == NULL)
m_pSinkClass = new CEventSink();

m_pSinkClass->DispEventAdvise((IDispatch*)m_pTransferModule,&DI ID_ITransferM

void CConsumerAccess::DetachEventSink()
m_pSinkClass->DispEventUnadvise((IDispatch*)m_pTransferModule );
delete m_pSinkClass ;
m_pSinkClass = NULL;
I don't know what could be causing this problem. Its definitely related to
the event sink because if I don't use it I don't get an access violation.

I would really appreciate some help on this.

Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.