Serialization & Events problem

  • Thread starter Thread starter Peter Tewkesbury
  • Start date Start date
P

Peter Tewkesbury

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
 
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 said:
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
 
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 said:
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

(e-mail address removed)

.
 
Back
Top