tags:

views:

56

answers:

2

I am having an issue with asp.net and a third party control that is embedded in a user control. I want to assign an event handler to one of the third party control's events. It allows the assignment but the event handler never get's touched. I believe that I am either messing up the event handler assignment or assigning it at the wrong time. I want to track the assignment of the event handler through debug. How can I inspect which event handlers are assigned to a control in debug?

+1  A: 

If you have the source for the user control, you can add some logging code to the add/remove accessors for the event.

In VS debugger, you can also check the contents of the _invocationList field in the event (base MulticastDelegate class). Expanding it will show you a list of attached handlers.

Groo
Unfortunately, I don't have the source.
A: 

Using the Watch (or Locals or Autos) window in Visual Studio, you can dig into the delegate holding the event (assuming it's a standard event) and see which method(s) it contains.

EDIT:

If the event only has one handler, you will see it in base.base.Method on the delegate field. If it has multiple handlers, base._invocationList will be an array of single-method delegates; you can check base.base.Method in each one.

If the _invocationList of a delegate isn't null, it's base.base.Method will be ignored.

SLaks
I can't seem to find any listing of the assigned methods.
See edit
SLaks