SelectionChangeEventHandler randomly disappears in Outlook 2007

  • Thread starter Thread starter bG9nc3Rlcg
  • Start date Start date
Status
Not open for further replies.
B

bG9nc3Rlcg

I've created an Outlook 2007 add-in via VS2008.

In the ThisAddIn_Startup method I attach a SelectionChangeEventHandler to

the Active Explorer selection change event via the following:

this.Application.ActiveExplorer().SelectionChange += new

Microsoft.Office.Interop.

Outlook.ExplorerEvents_10_SelectionChangeEventHandler(HelpdeskAddIn_SelectionChange);

This is to get the currently selected item.

Problem is the listener seems to stop working after a varying amount of

clicks/keyboards moves within the current mailbox window.

This sometimes happens after the 'reminders' window pops up, after opening

an email in a new inspector window or clicking about and using the cursor

keys.

Its confusing me as it doesn't seem to happen at the same point

consistently but on average after 20 new selections it disappears

Any ideas?
 
The garbage collector is removing the event handler. It's non-deterministic

as to when that would happen.

Make sure to declare at class level an Explorer object and instantiate that

and assign your event handler to that Explorer object. That way the garbage

collector won't remove the object or handler while the class that holds that

object is still in scope.

"logster" <logster> wrote in message

news:A2984D51-60D8-4271-B243-6B3C78DC6727@microsoft.com...
> I've created an Outlook 2007 add-in via VS2008.

> In the ThisAddIn_Startup method I attach a SelectionChangeEventHandler to
> the Active Explorer selection change event via the following:

> this.Application.ActiveExplorer().SelectionChange += new
> Microsoft.Office.Interop.

> Outlook.ExplorerEvents_10_SelectionChangeEventHandler(HelpdeskAddIn_SelectionChange);

> This is to get the currently selected item.

> Problem is the listener seems to stop working after a varying amount of
> clicks/keyboards moves within the current mailbox window.

> This sometimes happens after the 'reminders' window pops up, after opening
> an email in a new inspector window or clicking about and using the cursor
> keys.

> Its confusing me as it doesn't seem to happen at the same point
> consistently but on average after 20 new selections it disappears

> Any ideas?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
kburrows Outlook Email Body Text Disappears/Overlaps, Folders Switch Around when You Hover, Excel Opens Randomly and Runs in the Background - Profile Corrupt? Using Outlook 0
Horsepower Contact phone numbers randomly change Using Outlook 0
K Outlook 2019 Randomly Disconnecting from Gmail Servers Using Outlook 8
M Outlook 2016 Outlook randomly unhides from taskbar Using Outlook 12
P Outlook Randomly Not attaching (attachment file) Using Outlook 0
P AutoForward Randomly Doesn't fwd emails Using Outlook 3
O Outlook 2013 deleting emails randomly Using Outlook 0
B Outlook 2003 randomly not auto forwarding Using Outlook 0
S Outlook 2007 Rules randomly stopping working (non-Exchange Server) Using Outlook 6
A VBA Code in Outlook disappears after first use Outlook VBA and Custom Forms 1
D Body text of email disappears when I scan an attachment from printer to email Using Outlook 1
P when i move inbox mails to another folder in outlook the mail disappears Using Outlook 1
R Categorize Button in Quick Access Toolbar Disappears on New Email Using Outlook 1
Diane Poremsky Outlook's Folder Navigation Pane Disappears Using Outlook 2
Kristine RS box added in Favorites disappears Using Outlook 6
A Contact address disappears when opened to edit Using Outlook 5
A Form disappears when replying to it Using Outlook 4
J Outlook 2010 - email address disappears when setting up new contact Using Outlook 0
I Auto Complete disappears every time a user logs out Using Outlook 1
C Shared Contacts Folder Disappears from Other Contacts Using Outlook 3
D Outlook 2010 - email address disappears when setting up new contact Using Outlook 3
L BCM add-in disappears when changing profile BCM (Business Contact Manager) 0
M Group Calendar disappears Using Outlook 0
M Email Text Disappears Using Outlook 5
N Blocked senders list disappears Using Outlook 4
P Body disappears in 2002 when creating an item from a saves msgattachment Outlook VBA and Custom Forms 2
D Why does my Outlook 2003 .Com Add-In disappears after reboot! Outlook VBA and Custom Forms 4
Z Data disappears when custom form is sent Outlook VBA and Custom Forms 1

Similar threads

Back
Top