To future readers: I'd go with Avro or Protocol Buffers or even Thrift over MessagePack based on these results ...
For the sake of the specific question, the key portions are:
public byte[] Serialize<T>(T thisObj)
{
var serializer = MessagePackSerializer.Create<T>();
using (var byteStream = new MemoryStream())
{
serializer.Pack(byteStream, thisObj);
return byteStream.ToArray();
}
}
public T Deserialize<T>(byte[] bytes)
{
var serializer = MessagePackSerializer.Create<T>();
using (var byteStream = new MemoryStream(bytes))
{
return serializer.Unpack(byteStream);
}
}
The entire R&D type project, with results is at https://github.com/sidshetye/SerializersCompare and the specific function calls are here.