473,785 Members | 2,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Nov 21 '05 #1
0 897

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

Similar topics

0
1056
by: Jason | last post by:
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...
3
16333
by: mikeb | last post by:
I have a class (settings, etc.) which is derived from CollectionBase and contains a number of fields and a few events. When I create an instance of this class in my app, and serialize it, it works. If I add an event handler in my app (for one of the events in my settings class), I get an exception that my app class is not marked as Serializable. If I mark the app class as Serializible, I get an exception that Type System.Windows.Forms.Form...
0
1703
by: jan v | last post by:
Hi everyone I have a problem with events. When the code reaches communication.SynchronisationServer.UpdateNotificationEvent+=new Agilis.RAB.Server.BusinessLogic.SynchronisationDelegate(SynchronisationServer_UpdateNotificationEvent); communication.SynchronisationServer.UpdatedDataSenderEvent+=new Agilis.RAB.Server.BusinessLogic.SynchronisationDataSendingDelegate(SynchronisationServer_UpdatedDataSenderEvent); than it fires the...
5
15183
by: Neil Norfolk | last post by:
I am using C# in Visual Studio 2003. I would like to serialize a class that contains, amongst other things, public delegate void DocumentsPreferencesChange(object env, Documents e); public event DocumentsPreferencesChange OnDocumentsPreferencesChange; However, as it stands, the classes containing any methods/delegates that have been added to OnDocumentsPreferencesChange also have to be serializable: this I do not want. I do not actually...
0
252
by: Nigel Armstrong | last post by:
Hi All If I have a type that contains an event, then serialization tries to serialize the delegate and its invocation list - not good. In C#, I can write code like this (follows) - note the use of the NonSerialized attribute with the field qualifier . Without the field qualifier I get a compile time error. In VB.NET, I don't seem to have an equivalent - I can't do
7
1929
by: nick.fletcher | last post by:
I have a custom collection which derives from Collection<which stores a number of objects. Before each item is added to the collection - an event which it exposes is hooked by the collection and the re-fired to its parent. eg class MyCollection : Collection<MyType> { public AddAnObject(MyType obj)
0
1208
by: shivkumar2004 | last post by:
Hi, I m getting the following error while registering the events on client appl. error: "An error occurred creating the form. See Exception.InnerException for details. The error is: Exception has been thrown by the target of an invocation."
6
4812
by: Smithers | last post by:
Just looking to compile a list of "all the ways to implement events". I'm NOT looking to get into the merits or mechanics of each in this thread... just want to identify them all - good, bad, and ugly. Here's what I have so far 1. Implement via the 'event' keyword (with associated delegate, etc) 2. Expose a private delegate via a public property (really a "roll yer own" version of the 'event' keyword method).
2
1821
by: Rigor69 | last post by:
Hi There. I'm working on a application with a multiple level object structure. Object type "Cproject" holds an arraylist of "Csystem". A "Csystem" contain custom events i listen for in "Cproject" When i add items to the lists of "Csystem" i also add eventhandlers for the above events. When the object structure is serialized to an xml-file, and then deserialized, my event handlers are lost, since at the deserialization of "Cproject",...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.