I am working ona Windows CE 5.0 device with .net compact framework2.0.
I am trying to serialize this class (i'll summarize as the object is much 
bigger):

[ProtoContract]
public class Anag {
    public Anag() {
         persons = new Dictionary<String,Person>();
         adresses = new Dictionary<Int32, Address>;
    }
    
    [ProtoMember(1)]
    public Dictionary<String, Person> persons {get; set;};
    [ProtoMember(2)]
    public Dictionary<Int32, Address> addresses {get; set;};
}

[ProtoContract]
class Person {
        [ProtoMember(1)]
        public int Id {get;set;}
        [ProtoMember(2)]
        public string Name {get;set:}
}

[ProtoContract]
class Address {
        [ProtoMember(1)]
        public string Line1 {get;set;}
        [ProtoMember(2)]
        public string Line2 {get;set;}
}


I load up the Anag class with data the serialize with

Anag anag = loadAnag();
FileStream fs = File.Create(fileName);
Serializer.Serialize<Anag>(fs, ana);
fs.Close();

but i get:

System.Reflection.TargetInvocationException was unhandled
  Message="TargetInvocationException"
  StackTrace:
    at System.Reflection.RuntimePropertyInfo.GetValue()
    at ProtoBuf.Serializers.TupleSerializer.GetValue()
    at ProtoBuf.Serializers.TupleSerializer.Write()
    at ProtoBuf.Meta.RuntimeTypeModel.Serialize()
    at ProtoBuf.ProtoWriter.WriteObject()
    at 
ProtoBuf.Serializers.SubItemSerializer.ProtoBuf.Serializers.IProtoSerializer.Write()
    at ProtoBuf.Serializers.TagDecorator.Write()
    at ProtoBuf.Serializers.ListDecorator.Write()
    at ProtoBuf.Serializers.PropertyDecorator.Write()
    at ProtoBuf.Serializers.TypeSerializer.Write()
    at ProtoBuf.Meta.RuntimeTypeModel.Serialize()
    at ProtoBuf.Meta.TypeModel.SerializeCore()
    at ProtoBuf.Meta.TypeModel.Serialize()
    at ProtoBuf.Meta.TypeModel.Serialize()
    at ProtoBuf.Serializer.Serialize()
    [...]
  InnerException: 

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to