C#学习教程:Protobuf.netexception – 检查元数据时超时分享 您所在的位置:网站首页 python使用protobuf C#学习教程:Protobuf.netexception – 检查元数据时超时分享

C#学习教程:Protobuf.netexception – 检查元数据时超时分享

2022-12-28 04:03| 来源: 网络整理| 查看: 265

Protobuf.netexception – 检查元数据时超时

尝试使用protobuf.net反序列化对象时, 有时会收到以下exception。 我很惊讶,因为我从来没有多个线程同时反序列化同一个对象,并且protobuf.net源似乎没有使用任何静态对象进行反序列化。 exception确实提出了一个解决方案,但我不确定如何实现,所以欢迎一个例子。

Base Exception Type: System.TimeoutException: Timeout while inspecting metadata; this may indicate a deadlock. This can often be avoided by preparing necessary serializers during application initialization, rather than allowing multiple threads to perform the initial metadata inspection at ProtoBuf.Meta.RuntimeTypeModel.TakeLock(Boolean& lockTaken) at ProtoBuf.Meta.RuntimeTypeModel.FindOrAddAuto(Type type, Boolean demand, Boolean addWithContractOnly, Boolean addEvenIfAutoDisabled) at ProtoBuf.Meta.RuntimeTypeModel.GetKey(Type type, Boolean demand, Boolean getBaseKey) Inner Exception Type: System.TimeoutException: Timeout while inspecting metadata; this may indicate a deadlock. This can often be avoided by preparing necessary serializers during application initialization, rather than allowing multiple threads to perform the initial metadata inspection at ProtoBuf.Meta.RuntimeTypeModel.TakeLock(Boolean& lockTaken) at ProtoBuf.Meta.RuntimeTypeModel.FindOrAddAuto(Type type, Boolean demand, Boolean addWithContractOnly, Boolean addEvenIfAutoDisabled) at ProtoBuf.Meta.RuntimeTypeModel.GetKey(Type type, Boolean demand, Boolean getBaseKey) Stack Trace: at ProtoBuf.Meta.RuntimeTypeModel.GetKey(Type type, Boolean demand, Boolean getBaseKey) at ProtoBuf.Meta.TypeModel.GetKey(Type& type) at ProtoBuf.Meta.TypeModel.Deserialize(Stream source, Object value, Type type)

此致,马克

编辑添加:我定义了我的可序列化对象:

[ProtoContract] public class Job { [ProtoMember(1)] public long JobId { get; private set; } }

我很难在每个可序列化对象上轻松调用PrepareSerialiser,因为我在不同的命名空间中有很多。 但是考虑一下如果要求protobuf对同一类型的两个对象进行反序列化会发生什么呢?这个对象之前没有见过,类似于同一时间?



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有