473,386 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Getting the InvocationList for an event in a different class

I have a class with a DataTable built into it. Various places
subscribe to the DataTable.RowChanging event. I want to grab a list of
all the subscribers.

Normally I'd use GetInvocationList, but that only seems to work on
events that are defined in the same class. Events declared inside a
different class (even one inside the current one) won't let you use
that syntax.

Anyone got any ideas?

Thanks,

Andrew Ducker

Mar 21 '06 #1
3 4070
Dnia 21-03-2006 o 11:37:17 Andrew Ducker <an****@ducker.org.uk> napisał:
I have a class with a DataTable built into it. Various places
subscribe to the DataTable.RowChanging event. I want to grab a list of
all the subscribers.

Normally I'd use GetInvocationList, but that only seems to work on
events that are defined in the same class. Events declared inside a
different class (even one inside the current one) won't let you use
that syntax.

Anyone got any ideas?


[PD] If you really know what you are doing you can use Reflector to check
how looks add method for this event. If it's "standard" event without
custom add method C# compiler generates hidden field and add and remove
methods operating on it, so you can acces this hidden delegate using
reflection and get the invocation list. In other case you must analyze the
custom code to see where the added delegates are stored and also acces it
via reflection.

--
Piotr Dobrowolski
Piotr.Dobrowolski@_usun_gmail.com
Mar 21 '06 #2
Hi,


Normally I'd use GetInvocationList, but that only seems to work on
events that are defined in the same class. Events declared inside a
different class (even one inside the current one) won't let you use
that syntax.

Anyone got any ideas?


A possible workaround is to define the event in your outer class, all the
consumers hook to this event, then only you subscribe to the DataTable'e
event. In this case you can do as you usually do.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Mar 21 '06 #3
Andrew,

You cannot get the invocation list of event in other class. Events are
metadata objects only and they are set of 2 or 3 methods - add, remove and
invoke. How the events are implemented internaly is up to the implementing
classl it might use private field, collection of event handlers
(System.Windows.Forms controls for example) or maybe some other weird
method.

Keep in mind that invication list belongs to the delegate not the event
itself.
--
HTH
Stoitcho Goutsev (100)
"Andrew Ducker" <an****@ducker.org.uk> wrote in message
news:11*********************@e56g2000cwe.googlegro ups.com...
I have a class with a DataTable built into it. Various places
subscribe to the DataTable.RowChanging event. I want to grab a list of
all the subscribers.

Normally I'd use GetInvocationList, but that only seems to work on
events that are defined in the same class. Events declared inside a
different class (even one inside the current one) won't let you use
that syntax.

Anyone got any ideas?

Thanks,

Andrew Ducker

Mar 21 '06 #4

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

Similar topics

18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
2
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
6
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...
13
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the...
5
by: Charles Bazi | last post by:
Hi, I have a base UserControl named UserControlEx. I have created an event, and a dummy handler. Then I create several UCs with UserControlEx base. Some of those have a handler for my custom...
11
by: mark | last post by:
Right now I have a thread that sleeps for sometime and check if an event has happened and go back to sleep. Now instead I want the thread to sleep until the event has occured process the event and...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
16
by: Stefano Sabatini | last post by:
Hi all, I'm facing this design problem. I have a table which defines the behaviour of an Object in a given state according to the type of event it is receiving. So for each couple...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.