首页 > 解决方案 > protobuf-net 缓存模型吗?

问题描述

我正在使用 Marc Gravell 的 protobuf-net

https://github.com/protobuf-net/protobuf-net

我有他跟随的模型

[ProtoContract]
public class PageControlsM
{
    public PageControlsM()
    {
        PageControlsD = new ObservableCollection<PageControlsD>();
    }

    [ProtoMember(1)]
    [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int Id { get; set; }

    [ProtoMember(2)]
    public int PageRefno { get; set; }


    [ProtoMember(3)]
    public int OrderNo { get; set; }


    [ProtoMember(4)]
    public string ControlCode { get; set; }

    [ProtoMember(5)]
    [ForeignKey("ControlCode")]
    public  ControlTypes ControlTypes { get; set; }

    
    [ProtoMember(6)]
    [ForeignKey("ControlMRefNo")]
    public  ObservableCollection<PageControlsD> PageControlsD { get; set; }

}

我的模型中最初没有 OrderNo 属性。

所以我已经将它添加到我的模型中,并且可以看到用Protomember(3)属性标记它。

当我运行我的应用程序时,出现以下错误

ProtoBuf.ProtoException: 'Invalid wire-type (String); this usually means you have over-written a file without truncating or setting the length; see https://stackoverflow.com/q/2152978/23354'

如果我将 OrderNo 的 protomember 值从 3 更改为 6 并相应地编辑其余的 protomember 值,一切正常,那么它是否将生成的 protobuf 模型缓存在某处?

非常感谢任何帮助

编辑

我很抱歉造成混乱,原因是,我们正在从远程服务器运行 Web 应用程序,而我的同事一直在服务器上的 localhost:5000 上运行 grpc 服务器。我已将 grpc 配置为在 localhost:5010 上运行,但是在调用 grpc 服务器时我已将端点硬编码为 localhost:5000 .. 所以一切都很好!

标签: c#protobuf-net

解决方案


推荐阅读