Serialization problem

c#, serialization

Solution

I have written a tool called sertool that will tell you what in your object graph cannot be serialized and how it is being referenced.

Problem

The situation is like this : Main project A. and a class library B. A references B Project B has the classes that will be serialized. The classes are used in A. Now, the problem appears when from Project A I try to serialize the objects from B. An exception is thrown that says a class from A cannot be serialized. This is the strange part since in the classes in B I cant have a reference to those in A. (a circular dependency would be created). How can I track down the problem ? because the exception method doesn't say where the Problem appeared ? Edit : Ok, I found the problem with the help of Kent Boogaart's small app :D . I have a PropertyChanged listener in a class in project A that is not marked Serializable - and I don't want to mark it so. ( it would serialize that class to right ?) I've solved the problem with the event by following this link : .NET 2.0 solution to serialization of objects that raise events. There still is a problem , but it's probably something similar. PS: Great tool from Kent Boogaart

Original source