【问题标题】:Protobuf.net Portable Exception - Timeout while inspecting metadataProtobuf.net 便携式异常 - 检查元数据时超时
【发布时间】:2017-01-19 16:54:42
【问题描述】:

我正在使用可移植的 protobuf-net.dll 版本 2.0.0.668

我的单元测试一直抛出这个错误:

ProtoBuf.ProtoException : 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; please also see the LockContended event

我尝试了以下方法但没有成功:

Serializer.PrepareSerializer<ParametersSetRequestMessage>();

测试中没有线程。而且被序列化的类型并不复杂。

[ProtoContract]
public class ParametersSetRequestMessage: Message, IParameterMessage
{
    public ParametersSetRequestMessage()
    {
        Type = MessageType.ParametersSetRequest;
        BaseType = BaseMessageType.Command;
    }
    public MessageType Type { get; protected set; }

    [ProtoMember(1)]
    public List<ParameterSlim> SetParameters { get; set; }
}

[ProtoContract]
public class ParameterSlim
{
    [ProtoMember(1)]
    public ParameterId ParameterId { get; set; }

    [ProtoMember(2)]
    public byte[] RawBytes { get; set; }
}


[ProtoContract]
public class Message : IMessage
{
    public BaseMessageType BaseType { get; protected set; }

    [ProtoMember(1)]
    public DateTime ReceivedTime { get; set; }
}

有什么想法吗?

【问题讨论】:

    标签: c# protobuf-net portable-class-library


    【解决方案1】:

    好的 - 对于我的单元测试项目,我添加了不可移植的 nuget 包,现在一切正常。 便携式 dll 似乎存在问题。虽然我一直在 ios、Android 和 mono 上使用它,但没有任何问题。我的单元测试在 Windows 机器上运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-09
      • 1970-01-01
      相关资源
      最近更新 更多