我正在使用便携式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; }
}
有什么想法吗?
答案 0 :(得分:0)
好的 - 对于我的单元测试项目,我添加了非便携式nuget包,现在一切都好了。 便携式dll似乎存在问题。虽然我一直在ios,Android和单声道上使用它没有问题。我的单元测试是在Windows机器上运行的。