3
votes

I have an custom object I'm trying to serialize using Protobuf-net and the following exception is thrown:

InvalidOperationException was unhandled: Cannot write a Variant header until the String data has been written

The thing I'm finding interesting is that at no point in my object graph is there a string that is being serialized. Has anyone ever seen an error like this before and is there a known cause/fix? Thank you

1
In this context, "the String data" is talking about the protobuf wire specification, where "string" is a wire-type that doesn't necessarily mean "a string of text". Basically, it is usually "header, value, header, valye, ..." where the header includes (in very compressed form) the wire-type of the following value; hence, if it found itself writing "header, header", it knows that something is wrong, and it is complaining that no value was written for the first header, which happens to have been of type: "string". Overall though, I suspect this is a long-fixed bug. - Marc Gravell

1 Answers

1
votes

This looks a lot like the bug here:

https://code.google.com/p/protobuf-net/issues/detail?id=218.

Are you serializing a zero length byte[] at some point in your object?