Sure I'll help you out with this (since no one else could be bothered to even confirm/deny the symptoms).
I've found the problem indeed being the reader reading invalid data. However you can help it by writing a whitespace at the end of stream, like so:
//Serialize value
using (var memStream = new MemoryStream(buffer))
using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(memStream))
{
serializer.WriteObject(writer, testValue);
writer.WriteWhitespace(" ");
}
//Deserialize value
using (var memStream = new MemoryStream(buffer))
using (XmlDictionaryReader reader = XmlDictionaryReader.CreateBinaryReader(memStream, XmlDictionaryReaderQuotas.Max))
{
object deserializedValue = serializer.ReadObject(reader); // \o/
Console.WriteLine(deserializedValue);
}
Can't believe no one so much as favorited this question as it potentially leads to hard to debug exceptions at runtime and is thus making serializing objects with XmlDictionaryWriter a wee bit unreliable.
Connect report: https://connect.microsoft.com/VisualStudio/feedback/details/811170/xmlbinaryreader-not-able-to-read-from-fixed-size-buffer