Closed GoogleCodeExporter closed 8 years ago
The error message talks about ModelClass, but the question talks about
ReviewTopic - can you clarify?
Original comment by marc.gravell
on 30 Aug 2013 at 7:22
No modelClass here(just for example), I have modify the ReviewTopic below, the
exception gone ,But when I deserialize from memcache use the ProtoTranscoder, I
got the values Dictionary<string,List<ReviewTopic>> data, the List<ReviewTopic>
in dictionary has value ,but every ReviewTopic 's Property is empty .
[Serializable,DataContract]
public class ReviewTopic
{
[DataMember(Name="id")]
public int Id { get; set; }
[DataMember(Name = "title")]
public string Title { get; set; }
}
Original comment by liurongw...@gmail.com
on 30 Aug 2013 at 8:10
When I save the Dictionary<string,List<ReviewTopic>> data to memcache, Every
ReviewTopic property has value .
Original comment by liurongw...@gmail.com
on 30 Aug 2013 at 8:12
Indeed; if using the DataMember attributes you need to use the Order to control
serialization:
[DataMember(Name="id", Order=1)]
public int Id { get; set; }
[DataMember(Name = "title", Order=2)]
public string Title { get; set; }
protocol buffers is numbers-based, not name-based.
Original comment by marc.gravell
on 30 Aug 2013 at 8:33
thanks a ton ,it work,by the way , what 's best practice to use the
Serializable,DataContract,ProtoContract for protobuff serialization, and need I
mark all used property of a serializable class ?
I have some class which didn't have this problem ,it wase only marked as
[Serializable].
as you say 'protocol buffers is numbers-based, not name-based.', why my other
class worked correctly ?
[Serializable]
public class Impression
{
public int Id { get; set; }
public int SerialId { get; set; }
public string Keywords { get; set; }
public int Vote { get; set; }
public string Guid { get; set; }
}
this class when serialize with protobuff don't has exception ? so what 's the
correct way to use it ?
Original comment by liurongw...@gmail.com
on 30 Aug 2013 at 9:38
protobuf-net won't serialize that class *at all*; most likely that is working
because it is using some other serializer implementation - presumably
defaulting to BinaryFormatter for things that clearly aren't usable. Note,
protobuf-net also doesn't care whether or not something is marked
[Serializable] - it doesn't check for that and doesn't require that.
Original comment by marc.gravell
on 30 Aug 2013 at 10:03
Original issue reported on code.google.com by
liurongw...@gmail.com
on 30 Aug 2013 at 7:20