I have a list of objects of various data types (DateTime, int, decimal, string).
List<object> myObjects = new List<object>();
myObjects.Add(3);
myObjects.Add(3.9m);
myObjects.Add(DateTime.Now);
myObjects.Add("HELLO");
I was able to serialize this list using protobuf-net, but deserialization always throws the exception: "Additional information: Type is not expected, and no contract can be inferred: System.Object".
using (var ms = new MemoryStream())
{
Serializer.Serialize(ms, list2);
var bytes = ms.ToArray();
ms.Position = 0;
var clone = Serializer.Deserialize(typeof(List<object>), ms); //Throws exception
}
I don't have any explicit contract, I suppose that is the problem? However, I do know what are the expected types of serialized objects, but how do I tell to protobuf-net?