Hopefully I’m even asking my question correctly. I’m getting the following exception while trying to serialize a specific object (I’m familar with the using the standard [Serializable] attribute)
A first chance exception of type
‘System.Runtime.Serialization.SerializationException’ occurred in
mscorlib.dllAdditional information: Type ‘System.ComponentModel.Component’ in
Assembly ‘System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089’ is not marked as serializable.
I cannot find where the heck this is coming from. None of my classes inherit from Component, none of thier base classes inherit from component.
I’ve gotten to the point where I’m marking EVERY delegate\member varialbe as [NonSerialized], and its still throwing this exception every time I attempt to serialize.
So my question is: can I use this PublicKeyToken, and find what exact class\member is attempting to serialize?
I’ll give a guess based on having seen this too many times to count: you have an
event, and you have subscribed from that event to some UI code or something elseComponentrelated.When using
BinaryFormatter, events (or rather, the backing field) are serialized. If you don’t want this, ensure your events are marked:I’ll also note that so many (IMO, subjective) bad things happen when using
BinaryFormatterthat I really would suggest using something else. XmlSerializer for example (mutters something inaudible about a quite-populate open-source binary formatter also being available).