首页 > 解决方案 > 类型“Namespace.SomeAbstractType”只能参与一个继承层次结构(Namespace.InterfaceType)

问题描述

尝试使用 protobuf-net 进行序列化时,此错误意味着什么?

{"Type 'Namespace.SomeAbstractType' 只能参与一个继承层次结构(Namespace.InterfaceType)"}

堆栈跟踪

   at ProtoBuf.Meta.RuntimeTypeModel.GetKey(Type type, Boolean demand, Boolean getBaseKey)
   at ProtoBuf.Meta.ValueMember.TryGetCoreSerializer(RuntimeTypeModel model, DataFormat dataFormat, Type type, WireType& defaultWireType, Boolean asReference, Boolean dynamicType, Boolean overwriteList, Boolean allowComplexTypes)
   at ProtoBuf.Meta.ValueMember.BuildSerializer()
   at ProtoBuf.Meta.ValueMember.get_Serializer()
   at ProtoBuf.Meta.MetaType.BuildSerializer()
   at ProtoBuf.Meta.MetaType.get_Serializer()
   at ProtoBuf.Meta.RuntimeTypeModel.Serialize(Int32 key, Object value, ProtoWriter dest)
   at ProtoBuf.Meta.TypeModel.SerializeCore(ProtoWriter writer, Object value)
   at ProtoBuf.Meta.TypeModel.Serialize(Stream dest, Object value, SerializationContext context)
   at ProtoBuf.Meta.TypeModel.Serialize(Stream dest, Object value)
   at ProtoBuf.Serializer.Serialize[T](Stream destination, T instance)
   at Temp.Program.Main(String[] args) in D:\SOURCECODE\VISUALSTUDIO\AI\Dev\DevBranch\Temp\Program.cs:line 25
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

标签: protobuf-net

解决方案


推荐阅读