Messagepack无合约反序列化/

时间:2019-04-03 10:50:38

标签: serialization deserialization msgpack

我正在尝试将对象从字节数组中解序列化到字节数组中,在这里我无法控制要序列化的对象,因为这是一个库。

代码:(https://github.com/jonathansant/Orleans.Persistence.Redis/blob/master/Orleans.Persistence.Redis/Serialization/MessagePackSerializer.cs

在上面的粘贴存储库中,我使用的是Typeless名称空间,该名称空间适用于驻留在同一程序集中的类。但是,在外部程序集中创建的对象将失败。

我尝试使用Contractless解析器:

public byte[] Serialize(object raw, Type type)
    => MessagePack.MessagePackSerializer.NonGeneric.Serialize(
        type,
        raw,
        ContractlessStandardResolver.Instance
    );

public object Deserialize(byte[] serializedData, Type type)
    => MessagePack.MessagePackSerializer.NonGeneric.Deserialize(
        type,
        serializedData,
        ContractlessStandardResolver.Instance
    );

抛出:

System.TypeLoadException: Type 'MessagePack.Formatters.Orleans_GrainState`1\[\[Orleans_Persistence_Redis_E2E_MockState\, Orleans_Persistence_Redis_E2E\]\]Formatter1' from assembly 'MessagePack.Resolvers.DynamicContractlessObjectResolver, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is attempting to implement an inaccessible interface.

有什么想法可以实现吗?

0 个答案:

没有答案