I just replaced the previous protobuf-net build which I was using in my code base (version 2.0.0.480) with the latest build (version 2.0.0.580) – since there is no specific build against .Net 4.0 or .Net 4.5 in the latest protobuf version, I am referencing the net30 full dll in my projects.
When trying to serialize a complex type which includes a System.Xml.Linq.XElement I get an InvalidOperationException from the protobuf serializer – the exception message states :
“No serializer defined for type: System.Xml.Linq.XElement”
I am assuming that the lack of a serializer for XElement relates to the fact that there is no .Net 4.0 build (since I’m referencing v4.0.30319 of the System.Xml.Linq.dll in my project).
My project targets the .NET 4.5 platform – it works fine when referencing the protobuf-net V2.0.0.480 net40 build.
This looks like it is related to “parseable types” – things that don’t have inbuilt handling, but which meet certain patterns allowing them to be treated as a
string. This has caused a few problems in the past, so is optionally supported, via.AllowParseableTypes:Note that the reason I had to declare a
Foohere is that it looks like the “root object” handling (which is quite different to handling members / sub-objects) isn’t checking for parseable types; I’ll have to investigate why not and fix it. I would hope that the following would work (it doesn’t currently, but probably should):