I have two projects: A/B. Project A is the project that contains all of the winforms which are bound to objbects in B (logic items)
A has an object of type
A.Form
B has objects of type
B.Serializer
B.Logic
Now, A has a reference to B (but B does not have a reference to A) and A.Form contains a member variable of type B.Logic. At some point, when all of the data is stored in B.Logic I try to save this object to disk by calling B.Serializer(B.Logic).
At this point I get an error when serializing saying that A.From is not marked as serializable.
But the project B has NO reference to A at ALL and even if it did SOMEHOW have a member referencing A.Form, it shouldn’t even compile.
The usual culprit here is things like events (in
B.Logic), or other back-references to external objects. You can mark fields as not for serialization:or with field-like events:
As an aside – from the description, I assume that you are using
BinaryFormatter; personally, I have reservations about this – it is very brittle. I’d suggest something non-implementation-specific;XmlSerializer, protobuf-net, Json.NET, etc.