I currently have an issue in an ArcObjects ArcMap add-in where my event handlers are seemingly-randomly being unhooked from the event I'm trying to catch. I've spent some time looking for a way to list all delegates currently assigned for the event but I can't find a way to call Delegate.GetInvocationList() from the event interface.

When my add-in is created I execute the following to respond to the ActiveView SelectionChanged event:

IActiveViewEvents_Event activeViewEvent = (IActiveViewEvents_Event)ArcMap.Document.FocusMap;
activeViewEvent.SelectionChanged += new IActiveViewEvents_SelectionChangedEventHandler(this.onSelectionChanged);

Now I know that this event handler will be lost when the active view changes so I also have this:

IDocumentEvents_Event documentEvent = (IDocumentEvents_Event)ArcMap.Document;
documentEvent.ActiveViewChanged += new IDocumentEvents_ActiveViewChangedEventHandler(this.onActiveViewChanged);

which calls the previous code to re-add the SelectionChanged event handler.

At seemingly random intervals my application stops responding to the SelectionChanged event. I'm stopping on all CLR errors so I'm sure it's not a silent exception that's disabling my add-in.

What I'd really like is to be able to inspect the delegates assigned to the SelectionChanged event and see if mine needs re-adding, but so far no joy.

Any suggestions on what might be going wrong, or how to inspect the assigned event handlers would be VERY much appreciated!


I've since figured out a pattern to the madness. My tool will only run within an edit session if features are selected. One way I can replicate this behaviour is to 1) start an edit session 2) select some features 3) run my tool - copies selected features from one layer to another 4) stop editing (it doesn't matter whether I save my edits or not) 5) Now the selection changed event is no longer handled

Can anyone tell me why starting and then stopping editing would detach my selection changed event handlers?

  • Did you try it with member variables for IActiveViewEvents_SelectionChangedEventHandler and IDocumentEvents_ActiveViewChangedEventHandler, then remove it (using -= m_SelChangedHandler) when active view changes? Commented Jun 30, 2011 at 22:43
  • @Kitk Kuykendall - yes I tried this, it makes no difference. As the ActiveViewChanged event is not fired in this case it makes no difference.
    – tomfumb
    Commented Jun 30, 2011 at 23:52

2 Answers 2


Thanks for the interest on this question. I ended up using a different approach that actually works better in my situation and is more reliable.

Instead of using IActiveViewEvents::SelectionChanged I went with IEditEvents::SelectionChanged as I actually only needed to know if the selection changed while editing. As the editor object never changes the event handler is never lost so there's no need to reassign the handler.

I spent a while longer testing the original issue and I'm fairly confident it's an ArcObjects issue as I wasn't actually able to replicate it every time using the exact same sequence of events.

I'd still like to know if the list of delegates can be retrieved for an ArcObjects event but for now my original problem is solved.


I faced the same problem recently with WPF dockable window. Resolved this by using custom ArcMap extension code from an Esri's Selection Sample add-in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.