Hi,

I have a class which I have marked with the serializable
attribute. All the serialize code works untill I added an
event to the class. An now, when I come to serialize the
class, it wants to serialize the class where an event sink
is defined

I can only stop this by removing all the events from the
class before serialization, and adding them back after.

C# will not let me add [NonSerialized()] to the event
variable defintion.

Thanks

Peter Tewkesbury

Re: Serialization & Events problem by Dennis

Dennis
Mon Sep 15 08:17:48 CDT 2003

Hi Peter,

Don't kill me if I'm wrong, but you probably have to implement
ISerializable and control serialization and deserialization
yourself. For example, during deserialization you may need to
set-up the events again.

HTH

Peter Tewkesbury wrote:
> Hi,
>
> I have a class which I have marked with the serializable
> attribute. All the serialize code works untill I added an
> event to the class. An now, when I come to serialize the
> class, it wants to serialize the class where an event sink
> is defined
>
> I can only stop this by removing all the events from the
> class before serialization, and adding them back after.
>
> C# will not let me add [NonSerialized()] to the event
> variable defintion.
>
> Thanks
>
> Peter Tewkesbury


--
Dennis Doomen
Sioux T.S.O. Netherlands

dennis.doomen@sioux.nl


Re: Serialization & Events problem by Peter

Peter
Mon Sep 15 08:26:52 CDT 2003

Hi,

The solution is to move all events into a seperate class,
and include the class as a member var, and mark it as
being NonSerializable.

You end up with an extra level of indirection when typing
code which uses the events class.

Peter

>-----Original Message-----
>Hi Peter,
>
>Don't kill me if I'm wrong, but you probably have to
implement
>ISerializable and control serialization and
deserialization
>yourself. For example, during deserialization you may
need to
>set-up the events again.
>
>HTH
>
>Peter Tewkesbury wrote:
>> Hi,
>>
>> I have a class which I have marked with the
serializable
>> attribute. All the serialize code works untill I added
an
>> event to the class. An now, when I come to serialize
the
>> class, it wants to serialize the class where an event
sink
>> is defined
>>
>> I can only stop this by removing all the events from
the
>> class before serialization, and adding them back after.
>>
>> C# will not let me add [NonSerialized()] to the event
>> variable defintion.
>>
>> Thanks
>>
>> Peter Tewkesbury
>
>
>--
>Dennis Doomen
>Sioux T.S.O. Netherlands
>
>dennis.doomen@sioux.nl
>
>.
>