Question

I'm serializing the data in my app using custom serialization i.e. each of the classes I'm storing has the [Serializable] attribute and implements ISerializable. The object graph being serialized is reasonably complex with lots of cross-references between the objects/classes. The serialization works, but it's pretty slow. :(

By putting a breakpoint in each relevant class's GetObjectData method, I've found that I'm getting many, many more hits than I've got objects.

I'm confused - my understanding of the serialization framework was that it would store each object only once, even if the object graph contained multiple references to it. I assumed that this meant each object's GetObjectData method would need to be called only once during saving. Am I wrong?

And if so, is there anything I can do in this approach to reduce the number of calls to my classes' GetObjectData methods?

Thanks.

Was it helpful?

Solution

The MSDN docs do not guarantee just 1 call per object instance.

Have you tried this with different formatters? There are comments here to the effect that selected work was being done to improve this. specifically for Indigo (aka WCF).

It is not guaranteed that this method will be called only once per object instance during serialization. Therefore, the method should be implemented in such a way that its behavior will be the same regardless of the number of times it is called.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top