Protocol buffers 简单Protobuf网络代码在带有';没有为类型';定义序列化程序;

Protocol buffers 简单Protobuf网络代码在带有';没有为类型';定义序列化程序;,protocol-buffers,protobuf-net,xamarin.android,Protocol Buffers,Protobuf Net,Xamarin.android,以下代码与WP7和Windows上的代码一样工作,我现在正试图让它在MonoDroid上运行: [ProtoContract] public class SSDTO { [ProtoMember(1)] public Dictionary<string, string> Strings = new Dictionary<string, string>(50); [ProtoMember(2)] public Dictionary<s

以下代码与WP7和Windows上的代码一样工作,我现在正试图让它在MonoDroid上运行:

[ProtoContract]
public class SSDTO {
    [ProtoMember(1)]
    public Dictionary<string, string> Strings = new Dictionary<string, string>(50);

    [ProtoMember(2)]
    public Dictionary<string, int> Ints = new Dictionary<string, int>(50);

    [ProtoMember(3)]
    public Dictionary<string, byte[]> Bytes = new Dictionary<string, byte[]>(10);
}

public class SettingStore {
    public event EventHandler ContentsChanged;

    private Dictionary<string, string> _StringVals;
    private Dictionary<string, int> _IntVals;
    private Dictionary<string, byte[]> _ByteVals;

    public SettingStore() {
        _StringVals = new Dictionary<string, string>(50);
        _IntVals = new Dictionary<string, int>(50);
        _ByteVals = new Dictionary<string, byte[]>(10);
    }

    private SettingStore(SSDTO source) {
        _StringVals = source.Strings;
        _IntVals = source.Ints;
        _ByteVals = source.Bytes;
    }
[协议]
公共级SSDTO{
[原成员(1)]
公共字典字符串=新字典(50);
[原成员(2)]
公共词典Ints=新词典(50);
[原成员(3)]
公共字典字节=新字典(10);
}
公共类设置存储{
公共事件处理程序内容更改;
私人词典;
私人词典;
私人字典(字节);;
公共设置存储(){
_StringVals=新词典(50);
_IntVals=新词典(50);
_字节=新字典(10);
}
专用设置存储(SSDTO源){
_StringVals=source.Strings;
_IntVals=source.Ints;
_ByteVals=源字节;
}
//访问器已删除

    public static SettingStore DeSerialize(Stream data) {
        return new SettingStore(Serializer.Deserialize<SSDTO>(data));
    }

    public void Serialize(Stream Target) {
        Serializer.Serialize<SSDTO>(Target, toDTO());
    }

    private SSDTO toDTO() {
        return new SSDTO { Ints = this._IntVals, Strings = this._StringVals, Bytes = this._ByteVals };
    }

}
公共静态设置存储反序列化(流数据){
返回新的设置存储(序列化程序.反序列化(数据));
}
公共void序列化(流目标){
Serializer.Serialize(Target,toDTO());
}
私人SSDTO toDTO(){
返回新的SSDTO{Ints=this.\u IntVals,Strings=this.\u StringVals,Bytes=this.\u ByteVals};
}
}
我得到的例外情况是:

System.InvalidOperationException:没有为类型定义序列化程序:System.Collections.Generic.KeyValuePair`2[[System.String,mscorlib,Version=2.0.5.0,Culture=neutral,PublicKeyToken=7cec85d7bea7798e],[System.String,mscorlib,Version=2.0.5.0,Culture=neutral,PublicKeyToken=7cec85d7bea7798e]] 在ProtoBuf.Meta.ValueMember.BuildSerializer()[0x00000]中:0 在:0中的ProtoBuf.Meta.ValueMember.get_序列化程序()[0x00000]处 在ProtoBuf.Meta.MetaType.BuildSerializer()[0x00000]中:0 在:0中的ProtoBuf.Meta.MetaType.get_序列化程序()[0x00000]处 在ProtoBuf.Meta.RuntimeTypeModel.Serialize(Int32键,System.Object值,ProtoBuf.ProtoWriter dest)[0x00000]中:0 在ProtoBuf.Meta.TypeModel.SerializeCore(ProtoBuf.ProtoWriter,System.Object值)[0x00000]中:0 在ProtoBuf.Meta.TypeModel.Serialize(System.IO.Stream dest、System.Object值、ProtoBuf.SerializationContext上下文)[0x00000]中:0 在ProtoBuf.Meta.TypeModel.Serialize(System.IO.Stream dest,System.Object value)[0x00000]中:0 在ProtoBuf.Serializer.Serialize[SSDTO](System.IO.Stream destination,ABC.SystemModel.SSDTO instance)[0x00000]中:0 在C:\CODE\SettingStore.cs:145中的ABC.SystemModel.SettingStore.Serialize(System.IO.Stream Target)[0x00002]处


我从源主干中的Monodroid项目中为Monodroid编译了protobuf net,这是我3-4天前抓到的;这是一个偶然的回归,因为Mono KeyValuePair具有不同于.NET的访问器,并且新的“元组”处理不同意它是一个合适的匹配(基本上,在Mono中,它们有私有setter,这与它无关)


我将在这个周末修复并重新部署。我诚挚的道歉。

嗯,总是最微小的事情让你。。。谢谢!=)@tempy为了获取信息,我在本地修补了这个问题——只是运行测试套件等。令人不快的Mono代码:(protobuf net需要“适当的”不可变元组)那些不必要的设置程序看起来很无辜。r447现在可以下载;请让我知道这两种方法是否解决了这个问题是的,解决了我的问题,再次感谢!