Just wanted to share an observation about the R561 version of protobuf-net. When using DateTimeOffSet
, an exception
InvalidOperationException (No serializer defined for type: System.DateTimeOffset)
appears:
I added a method with a getProto()
and a StreamWriter
to write a proto file, and now it works!(and the proto files is totally usable too). But if I comment this method, the same exception occurs. I really don't get it.
Hope this observation could be useful.
I will try to be clearer. I have a C# client with some objects using DateTimeOffset parameters. I serialized them with protobuf-net (r561), and added a writeProtoFile() method to write a proto file with the method getProto(). The serialization seems to work perfectly and the proto file is ok too. So because i have my proto file now, i can comment or supress the method writeProtoFile(): i do not need others proto files. So here's my first question:
-> Why the serialization don't work anymore when this method (that is just writting a proto file invoking the getProto() method) is commented or supress? Here's the exception I got:
No serializer defined for type: System.DateTimeOffset.
And when I uncomment the writeProtoFile() comment, it works. Here's the method:
public static void writeProtoFile(String proto)
{
StreamWriter file = new StreamWriter("c:\\MyprotoFiles\\MyProtoFile.proto");
file.Write(proto);
file.Close();
}
I need this object to be consumed by a java client. The java class generated with the proto compiler seems ok, but when I deserialize it, I got an exception :
com.google.protobuf.InvalidProtocolBufferException: While parsing a protocol message, the input ended unexpectedly in the middle of a field. This could mean either than the input has been truncated or that an embedded message misreported its own length.
I think, the reason is the DateTimeOffset class generated (In the proto, dateTimeOffset contains nothing)
message DateTimeOffset {
}
The type DateTimeOffset exists in Java, so here's my second question: -> Is there any way that a dateTimeOffset parameter in C# can be serialialized and then, be a dateTimeOffset parameters in java after deserialization?