Subject: Re: How do you stop Events being Serialized?
Date: Wed, 15 Oct 2003 20:19:00 +0100
Lines: 57
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <eZS4PG1kDHA.2416@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: modem-636.lemur.dialup.pol.co.uk 217.135.130.124
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:147002
X-Tomcat-NG: microsoft.public.dotnet.languages.vb
Thanks a lot, At least I can stop looking for something that does not exist.
I'll look into those suggestions you made.
Regards
Neal
Jay B. Harlow said:
Neal,
Unfortunately VB.NET does not support the NonSerialized attribute on events
(VB.NET does not have a Field Attribute Modifier, as shown in your other
post.).
The three methods I know of are:
1. Define your events in a C# base class that defines the event as being not
serializable (via [field: NonSerializable] or event procedures).
2. Implement the ISerializable interface and serialize only actual fields.
3. Create a SerializationSurrogate object that only serializes the actual
fields.
For details on the third method see the "Possible Solution to Serializing
Event Handlers in VB" thread from 10 Oct 2003 in the
microsoft.public.dotnet.distributed_apps &
microsoft.public.dotnet.framework.remoting newsgroups.
Because I need ISerializable for version control, I'm using the second
method.
Hope this helps
Jay
Neal Andrews said:
Hi All,
Does anyone know how to stop Events from being serialized in a class that
uses the <Serializable()> attribute?
I have tried using the <NonSerialized()> attribute but for some bizarre
reason, it is not allowed on events.
I am using VS 2003, if that makes any difference. The only thing I can think
of is to wrap all the events in a separate class and then not to mark the
class as Serializable.
TIA
Regards
Neal