【发布时间】:2018-06-23 16:28:23
【问题描述】:
我正在考虑替换 ASF 中 RPC 的默认序列化程序。这涉及实现一些接口,其中一个在通过 RPC 通信的服务之间传递
public interface IServiceRemotingResponseMessageBody
{
void Set(object response);
object Get(Type paramType);
}
由于实现需要可序列化,显而易见的 ProtoBuf 实现类似于
[ProtoContract]
public class ProtoBufRemotingResponseBody : IServiceRemotingResponseMessageBody
{
[ProtoMember(1)]
public object Value { get; set; }
public void Set(object response)
{
Value = response;
}
public object Get(Type paramType)
{
return Value;
}
}
不幸的是,这失败了
没有为类型定义序列化程序:System.Object
这里有解决方法吗? System.Object 没有合同,但 OOTB DataContract 序列化程序可以,MessagePack here 也可以,但是这些没有被模式化,这在使用 reliable collections 时会产生版本控制问题。我尝试过使用通用的基本类型,但 Value 可以是 IEnumerable<T> 或 T 等。
有人可以帮忙吗? 谢谢, KH
【问题讨论】:
标签: azure-service-fabric protobuf-net service-fabric-stateful protobuf-csharp-port