471,337 Members | 1,000 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

VB.NET, Events, and Serialization

I have a class which inherits from CollectionBase. My version adds events to
notify client whenever items are added or removed from the collection. I
wrote it in VB.NET.

If I have a class which creates an instance of the collection and adds
handlers to the events it raises, and then try to serialize the collection I
get an error about the client not being marked as serialized. This is
because of the reference the collection maintains (actually its delegate if
I understand it correctly) to any clients receiving its events. I tried to
marked the events as NonSerialized but that does not work since the
attribute can only be used on fields. So my solution was to implement
ISerializable but I could not get the deserialization to work since a
collection can have any type of object and when you are reading it back in
you do not know how to cast it.

This leads up to my actual question. Is there a way to look at an instance
of an object and find out who is listening for its events? More specially,
can I remove all the listeners from the events list if I just have a
reference to the collection object?

- Jason
Jul 21 '05 #1
0 950

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by mikeb | last post: by
reply views Thread by jan v | last post: by
5 posts views Thread by Neil Norfolk | last post: by
reply views Thread by Nigel Armstrong | last post: by
reply views Thread by Jason | last post: by
reply views Thread by Jason | last post: by
7 posts views Thread by nick.fletcher | last post: by
6 posts views Thread by Smithers | last post: by

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.