After updating to the latest protobuf-net (2.0.0.601) I now get an exception when trying to serialize a value of type System.Version.
[ProtoContract(SkipConstructor=true)]
public class ServerLoginInfo
{
[ProtoMember(1)]
public Version ServerVersion { get; set; }
}
This used to work fine in 2.0.0.480 without doing anything special.
Is it possible to get it working in the new version or is my only option to rollback to the old version?
(I also need the serialization/deserialization to be backwards compatible with the old protobuf-net version.)
I suspect this relates to AllowParseableTypes - i.e. whether it looks for a static Parse method as a fallback. If i remember, this can't be enabled on the default model, but I think I'll remove that restriction in the next deploy. But for now:
var model = TypeModel.Create();
model.AllowParseableTypes = true;
Then store model (and reuse it), and use model.Serialize/model.Deserialize.
If I change this default-model restriction, then just:
RuntimeTypeModel.Default.AllowParseableTypes = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With