You should never add generic type definitions manually to the protobuf-net RuntimeTypeModel. This is my issue. Closed.
Protobuf-net deserialization BadImageFormatException with serialization assembly compilation
-
06-08-2022 - |
Question
My class causes BadImageFormatException (HRESULT: 0x8007000B) in MySerializer.Deserialize(Int32, Object, ProtoReader).
The class is not used anywhere. It's only manually added to the type model and compiled to the assembly.
Without this class everything is ok.
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;
}
}
}
What could be the reason?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow