Loosing EventHandlers

C

Chris Walter

Hi,
I register the ItemAdd, ItemChange and ItemRemove Events
for my calendar,
<code>
Handles.TheLocalCalendar.Items.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventH
andler(CalSync.Event_ItemAdd_im_lokalen_Kalender);
</code>
after a period of time the events won't fire no more.
Any idea what could cause this?

I tried to reassign the Eventhandler through a timer, but
if I only add a new Eventhandler, the Event fires more
than once.

When I first try to delete the current Eventhandler
<code>
Handles.TheLocalCalendar.Items.ItemAdd -= new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventH
andler (CalSync.Event_ItemAdd_im_lokalen_Kalender);
</code>
I get a NullReferenceException (even if I define an
object for the eventhandler).

Is there a way to determine if the Event is
still "alive", or is there another way to remove
eventhandlers from events?

TIA

Chris Walter
 
D

Dmitry Streblechenko \(MVP\)

Make a variable that points to Items a global (class) variable:

m_Items = Handles.TheLocalCalendar.Items;
m_Items.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(CalSync.Eve
nt_ItemAdd_im_lokalen_Kalender);


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top