Serialization & Events problem

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
 
D

Dennis Doomen

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
 
P

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)

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top