Skip to content

热更工程中的数据类包含非热更工程中的类时,反序列化报错 #4

Closed
@shixianming

Description

@shixianming

obj is null.
Local Variables:

T v0 = null, IOException ex = null, T v2 = null
IL_0012: call System.Object ProtoBuf.Serializer::Deserialize(System.Type,System.IO.Stream)
at ProtobufHelper.ProtoDeSerialize(Byte[] msg) D:\Project\cross-gate-client\Assets\Scripts\HotUpdate\Protobuf\ProtobufHelper.cs:Line 39
at Demo.Test() D:\Project\cross-gate-client\Assets\Scripts\HotUpdate\Protobuf\Demo.cs:Line 32

ProtoBuf.ProtoException: obj is null.
  at ProtoBuf.Serializers.TypeSerializer.CreateInstance (ProtoBuf.ProtoReader source, System.Boolean includeLocalCallback) [0x00179] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\Serializers\TypeSerializer.cs:331 
  at ProtoBuf.Serializers.TypeSerializer.Read (System.Object value, ProtoBuf.ProtoReader source) [0x00094] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\Serializers\TypeSerializer.cs:209 
  at ProtoBuf.Meta.RuntimeTypeModel.Deserialize (System.Int32 key, System.Object value, ProtoBuf.ProtoReader source) [0x00082] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\Meta\RuntimeTypeModel.cs:839 
  at ProtoBuf.ProtoReader.ReadTypedObject (System.Object value, System.Int32 key, ProtoBuf.ProtoReader reader, System.Type type) [0x00033] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\ProtoReader.cs:607 
  at ProtoBuf.ProtoReader.ReadObject (System.Object value, System.Int32 key, ProtoBuf.ProtoReader reader) [0x00001] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\ProtoReader.cs:594 
  at ProtoBuf.Serializers.SubItemSerializer.ProtoBuf.Serializers.IProtoSerializer.Read (System.Object value, ProtoBuf.ProtoReader source) [0x00001] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\Serializers\SubItemSerializer.cs:81 
  at ProtoBuf.Serializers.TagDecorator.Read (System.Object value, ProtoBuf.ProtoReader source) [0x00049] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\Serializers\TagDecorator.cs:80 
  at ProtoBuf.Serializers.FieldDecorator.Read (System.Object value, ProtoBuf.ProtoReader source) [0x0000b] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\Serializers\FieldDecorator.cs:39 
  at ProtoBuf.Serializers.TypeSerializer.Read (System.Object value, ProtoBuf.ProtoReader source) [0x0010b] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\Serializers\TypeSerializer.cs:226 
  at ProtoBuf.Meta.RuntimeTypeModel.Deserialize (System.Int32 key, System.Object value, ProtoBuf.ProtoReader source) [0x00082] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\Meta\RuntimeTypeModel.cs:839 
  at ProtoBuf.Meta.TypeModel.DeserializeCore (ProtoBuf.ProtoReader reader, System.Type type, System.Object value, System.Boolean noAutoCreate) [0x0001f] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\Meta\TypeModel.cs:764 
  at ProtoBuf.Meta.TypeModel.Deserialize (System.IO.Stream source, System.Object value, System.Type type, ProtoBuf.SerializationContext context) [0x0002a] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\Meta\TypeModel.cs:627 
  at ProtoBuf.Meta.TypeModel.Deserialize (System.IO.Stream source, System.Object value, System.Type type) [0x00001] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\Meta\TypeModel.cs:604 
  at ProtoBuf.Serializer.Deserialize (System.Type type, System.IO.Stream source) [0x00001] in D:\Project\cross-gate-client\Assets\ThirdParty\Protobuf\protobuf-net-v2-for-ILRuntime\protobuf-net\Serializer.cs:94 
  at ILRuntime.Runtime.Generated.ProtoBuf_Serializer_Binding.Deserialize_1 (ILRuntime.Runtime.Intepreter.ILIntepreter __intp, ILRuntime.Runtime.Stack.StackObject* __esp, System.Collections.Generic.IList`1[T] __mStack, ILRuntime.CLR.Method.CLRMethod __method, System.Boolean isNewObj) [0x0006b] in D:\Project\cross-gate-client\Assets\Scripts\System\ILRuntime\Generated\ProtoBuf_Serializer_Binding.cs:96 
  at (wrapper delegate-invoke) <Module>.invoke_StackObject*_ILIntepreter_StackObject*_IList`1<object>_CLRMethod_bool(ILRuntime.Runtime.Intepreter.ILIntepreter,ILRuntime.Runtime.Stack.StackObject*,System.Collections.Generic.IList`1<object>,ILRuntime.CLR.Method.CLRMethod,bool)
  at ILRuntime.Runtime.Intepreter.ILIntepreter.Execute (ILRuntime.CLR.Method.ILMethod method, ILRuntime.Runtime.Stack.StackObject* esp, System.Boolean& unhandledException) [0x033e4] in D:\Project\cross-gate-client\Packages\com.ourpalm.ilruntime@1.6.6\Runtime\Intepreter\ILIntepreter.cs:1823 

UnityEngine.Debug:LogError (object)
ApplicationManager/<>c:<Start>b__1_0 (System.Exception) (at Assets/Scripts/System/ApplicationManager.cs:51)
UniRx.MainThreadDispatcher:UnsafeSend (System.Action) (at Assets/Plugins/UniRx/Scripts/UnityEngineBridge/MainThreadDispatcher.cs:276)
UniRx.Scheduler/IgnoreTimeScaleMainThreadScheduler/<DelayAction>d__2:MoveNext () (at Assets/Plugins/UniRx/Scripts/UnityEngineBridge/MainThreadScheduler.cs:240)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)

--热更工程的类

[ProtoBuf.ProtoContract]
public class HotData
{
    [ProtoBuf.ProtoMember(1)]
    public string msg;

    [ProtoBuf.ProtoMember(2)]
    public Data data;
}

--非热更工程的类

[ProtoBuf.ProtoContract]
public class Data
{
    [ProtoBuf.ProtoMember(1)]
    public int id;

    [ProtoBuf.ProtoMember(2)]
    public string name;

    [ProtoBuf.ProtoMember(3)]
    public Label label;

    [ProtoBuf.ProtoContract]
    public enum Label
    {
        A,
        B,
        C
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions