Is there a possibility to skip the next 'entry' of a serialized stream when deserializing? Regarding a plugin-oriented architecture it can happen that distinct parts of a serialized object graphs might become unknown types in another environment (assume they could be safely ignored). Trying to deserialize these will of course fail.
abstract class Thing{}
class OneThing : Thing {} // <-- known in environment A & B
class SomeThing : Thing {} // <-- only known in environment A
...
var things = new List<Thing>();
...
things.Add( (OneThing)(formatter.Deserialize(stream)) );
things.Add( (SomeThing)(formatter.Deserialize(stream)) ); // <-- skip in B
things.Add( (OneThing)(formatter.Deserialize(stream)) );
How to get this working with the binary formatter? Do I have to calculate the length and retrieve an unambigous type-name (e.g. as string) of the serialized entry and store it right before the entry itself, so I can skip over it when deserializing (by incrementing the stream pointer)? Or is there a better alternative with less problem specific manipulation of the serialized representation?