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

Home Posts Topics Members FAQ

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 1056

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

Similar topics

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
0
897
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...
0
221
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...
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).
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
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10090
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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...
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.