473,324 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Event sink causing access violation

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:

namespace
{
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>
{
public:
CEventSink();
virtual ~CEventSink();
CConsumerAccess* m_pParent;
inline void SetParent(CConsumerAccess* pParent= NULL) { m_pParent =
pParent; }
void __stdcall OnUpdateProgress( long lResult);

BEGIN_SINK_MAP(CEventSink)

SINK_ENTRY_INFO(EVENT_ID,DIID_ITransferModuleEvent ,DISPID_UPDATE_PROGRESS,On
UpdateProgress,&OnUpdateProgressInfo)
END_SINK_MAP()

};
I attach and detach the event sink in my COM object code in the following
way:

void CConsumerAccess::EnsureEventSinkAttached()
{
if(m_pSinkClass == NULL)
{
m_pSinkClass = new CEventSink();
m_pSinkClass->SetParent(this);

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

void CConsumerAccess::DetachEventSink()
{
if(m_pSinkClass)
{
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
0 1367

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: BlueMonkMN | last post by:
I've been trying to think of the right way to design relationships between objects with different desired lifetimes that raise events. If an event source is a relatively permanent object and the...
0
by: Michael Cleroux | last post by:
Hi there, I read this in the Access 2002 help file: 'The class that raises an event is the event source, and the classes that implement the event are the sinks. An event source can have...
4
by: astro | last post by:
I've been looking at the event sinking example in Litwin et. al. "Access 97 Developer's Handbook" and I am able to event sink the 2 events listed - those being the "_quit" and "_documentchange"...
1
by: Bob Whiton | last post by:
I have an unmanaged class which has a member variable: gcroot<DataTable*> myDataTable; I would like to sink the RowDeleting event in my UNmanaged class. However, I can't declare an event...
0
by: Arnaud Debaene | last post by:
Hello all. I've got a bunch of existing, non managed, C++ DLLs that export types with, among other things, public events implemented using the boost::signals library. Now, I need to have...
2
by: Boris Fortes | last post by:
I need to unhook event receiver as result of native C++ event. It unhooks successfully, but __raise does not return and throws access violation. Visual Studio 2003 How to reproduce: Consol...
6
by: Charles Law | last post by:
I have a class, which implements an interface. Let's say, that the interface looks something like Public Interface IEventSinks Sub ValueChanged(sender As Object, e As ValueChangedEventArgs) Sub...
7
by: Don | last post by:
Getting errors after following the MSDN article on using VB.NET (and VS2005) for "Implementing a Managed OnSave Event Sink" for Exchange Server 2007. Not sure, but part of the problem may be that...
5
by: =?Utf-8?B?Q29kZVJhem9y?= | last post by:
I have an event sink which does some work to the software we use, according to the data contained within an email. This is all working hunky dory. What i want to know is whether it is possible to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.