【问题标题】:Protobuf-net deserialization BadImageFormatException with serialization assembly compilationProtobuf-net 反序列化 BadImageFormatException 与序列化程序集编译
【发布时间】:2013-12-01 14:10:02
【问题描述】:

我的课程在 MySerializer.Deserialize(Int32, Object, ProtoReader) 中导致 BadImageFormatException (HRESULT: 0x8007000B)。

该类不在任何地方使用。它只是手动添加到类型模型并编译到程序集中。

没有这个类一切都好。

    using System;
    using ProtoBuf;

    namespace MyProject
    {
        [ProtoContract(ImplicitFields = ImplicitFields.PublicProperties, ExplicitPropertiesContract = true, IgnoreListHandling = true, AsReferenceDefault = true)]
        [Serializable]
        public class DataSharedStorage<T>
        {

            T _value;

            public DataSharedStorage()
            {
            }

            public T Value
            {
                get
                {
                     return _value;
                }

                set
                {
                     _value = value;
                }
            }

            public static implicit operator T(DataSharedStorage<T> storage)
            {
                return storage.Value;
            }
         }
    }

可能是什么原因?

【问题讨论】:

    标签: c# .net serialization protobuf-net


    【解决方案1】:

    您永远不应将泛型类型定义手动添加到 protobuf-net RuntimeTypeModel。这是我的问题。关闭。

    【讨论】:

      猜你喜欢
      • 2012-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多