473,732 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_P ROGRESS = 1;//disp id of UpdateProgress. ..

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

}

class CEventSink : public
IDispEventSimpl eImpl<EVENT_ID, CEventSink,&DII D_ITransferModu leEvent>
{
public:
CEventSink();
virtual ~CEventSink();
CConsumerAccess * m_pParent;
inline void SetParent(CCons umerAccess* pParent= NULL) { m_pParent =
pParent; }
void __stdcall OnUpdateProgres s( long lResult);

BEGIN_SINK_MAP( CEventSink)

SINK_ENTRY_INFO (EVENT_ID,DIID_ ITransferModule Event,DISPID_UP DATE_PROGRESS,O n
UpdateProgress, &OnUpdateProgre ssInfo)
END_SINK_MAP()

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

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

m_pSinkClass->DispEventAdvis e((IDispatch*)m _pTransferModul e,&DIID_ITransf erM
oduleEvent);
}
}

void CConsumerAccess ::DetachEventSi nk()
{
if(m_pSinkClass )
{
m_pSinkClass->DispEventUnadv ise((IDispatch* )m_pTransferMod ule);
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 1396

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

Similar topics

0
1366
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 event sink is on an object that can come and go, what is the proper way to deal with adding and removing the handler to the event list? Should the event sink make sure to remove itself from the source's event list before all other references to it...
0
1531
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 multiple sinks for the events it generates. When the class raises the event, that event is fired on every class that has elected to sink events for that instance of the object.'
4
2399
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" events described and coded for in the examples mdb file.. However - some other important events I cannot get to work - some are: DocumentBeforeClose DocumentBeforePrint DocumentBeforeSave
1
1944
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 handler in the unmanaged class because the types are managed (compiler error C3265). For example, I can't declare the following sink: static void Row_Deleting(Object* sender, System::Data::DataRowChangeEventArgs* e)
0
1943
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 these DLL interoperate with managed code. Among others things, the managed code need to be able to register for notification with the boost signals. I've tried different approaches (trying to register a pinned delegate with the boost::signal, etc...),
2
2859
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 Win32 exe project
6
1786
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 StateUpdated(sender As Object, e As StateUpdatedEventArgs) End Interface In practice, the interface contains many more event handlers like this, but you get the picture.
7
5132
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 it's the 64-bit version of Exchange 2007 installed on Windows Server 2003 Enterprise x64, while the Exchange 2007 SDK samples seem mostly geared toward 32-bit. Even at that, I was able to build the TLB and install it into COM+ Component Services,...
5
1287
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 send an email from inside of an event sink. So for example an email comes into the event sink, and then the event sink generates a new email which it then sends. The reason I ask this is because the event sink code sits on the exchange...
0
8944
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8773
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9445
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9234
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9180
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6733
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3259
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.