Serialization [modified]
-
I'm trying to serialize an instance of a class with members of type bool, string, double[], double, int and an enumeration declared serializable. The class is marked
[Serializable()]
and doesn't have any child objects aside from the primitives mentioned. Also, it doesn't extend any other class: It's declared:[Serializable()]
public sealed class EQbandWhile serializing the object I get an error:
System.Runtime.Serialization.SerializationException: Type 'CtlEQ.CtlEQ' in Assembly 'bla, Version=2.0.2386.18258, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
I can't figure out why an attempt is made to serialize some instance of the CtlEQ class. The class I'm serializing is declared within the same namespace and is used by the CtlEQ.CtlEQ class (CtlEQ holds a refference to EQBand), but is no member of it. Does anyone know why this attempt is made and how I can prevent this from happening?
-
Just a wild guess: Do you have an event in EQband which CtlEQ listens to?
-
I'm trying to serialize an instance of a class with members of type bool, string, double[], double, int and an enumeration declared serializable. The class is marked
[Serializable()]
and doesn't have any child objects aside from the primitives mentioned. Also, it doesn't extend any other class: It's declared:[Serializable()]
public sealed class EQbandWhile serializing the object I get an error:
System.Runtime.Serialization.SerializationException: Type 'CtlEQ.CtlEQ' in Assembly 'bla, Version=2.0.2386.18258, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
I can't figure out why an attempt is made to serialize some instance of the CtlEQ class. The class I'm serializing is declared within the same namespace and is used by the CtlEQ.CtlEQ class (CtlEQ holds a refference to EQBand), but is no member of it. Does anyone know why this attempt is made and how I can prevent this from happening?
Just a wild guess: Do you have an event in EQband which CtlEQ listens to?
-
Well if you bind an event of class A from class B then internally you are setting a reference from A to B. Add the following to not serialize your event:
[field:NonSerializedAttribute()]
public event EventHandler FooEvent; -
Well if you bind an event of class A from class B then internally you are setting a reference from A to B. Add the following to not serialize your event:
[field:NonSerializedAttribute()]
public event EventHandler FooEvent;