JasonXuDeveloper / Nino

Definite useful and high performance serialization library for any C# projects, including but not limited to .NET Core apps or Unity/Godot games.
https://nino.xgamedev.net
MIT License
468 stars 44 forks source link

在je热更新工程 有问题 #56

Closed fenglindubu closed 1 year ago

fenglindubu commented 1 year ago

序列化类 放在主工程

using Nino.Serialization;

namespace NinoData.Chat
{
    [NinoSerialize]
    public partial class SystemData
    {
        [NinoMember(1)]
        public string name;
        [NinoMember(2)]
        public string notice;
    }
}

主工程测试 测试ok

var data = Nino.Serialization.Serializer.Serialize(new NinoData.Chat.SystemData() { name = "111", notice = "bbb" });
        Nino.Serialization.Deserializer.Deserialize< NinoData.Chat.SystemData> (data);
        Debug.LogError("主工程ok");

热更工程

        NinoData.Chat.SystemData systemData = new NinoData.Chat.SystemData() { name = "123" };
            var dt = Nino.Serialization.Serializer.Serialize(systemData);
          var data =  Nino.Serialization.Deserializer.Deserialize<NinoData.Chat.SystemData> (dt);

报错:

InvalidOperationException: Failed to retrieve unbox type Nino.Serialization.Serializer.Serialize[T] (System.Type type, T value, Nino.Serialization.Writer writer, Nino.Serialization.CompressOption option, System.Boolean returnValue) (at Assets/Dependencies/Nino/Serialization/Serializer.cs:215) Nino.Serialization.Serializer.Serialize[T] (System.Type type, T value, Nino.Serialization.Writer writer, Nino.Serialization.CompressOption option, System.Boolean returnValue) (at Assets/Dependencies/Nino/Serialization/Serializer.cs:211) Nino.Serialization.Serializer.Serialize[T] (T val, Nino.Serialization.CompressOption option) (at Assets/Dependencies/Nino/Serialization/Serializer.cs:51) System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <1f66344f2f89470293d8b67d71308c07>:0) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <1f66344f2f89470293d8b67d71308c07>:0) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <1f66344f2f89470293d8b67d71308c07>:0) ILRuntime.CLR.Method.CLRMethod.Invoke (ILRuntime.Runtime.Intepreter.ILIntepreter intepreter, ILRuntime.Runtime.Stack.StackObject esp, System.Collections.Generic.List`1[T] mStack, System.Boolean isNewObj) (at Assets/Dependencies/ILRuntime/ILRuntime/CLR/Method/CLRMethod.cs:346) ILRuntime.Runtime.Intepreter.ILIntepreter.Execute (ILRuntime.CLR.Method.ILMethod method, ILRuntime.Runtime.Stack.StackObject esp, System.Boolean& unhandledException) (at Assets/Dependencies/ILRuntime/ILRuntime/Runtime/Intepreter/ILIntepreter.cs:2103) Rethrow as ILRuntimeException: Exception has been thrown by the target of an invocation. IL_004b: call System.Byte[] Nino.Serialization.Serializer::Serialize(!!0,Nino.Serialization.CompressOption) UI.LoginGame.LoginGame.Start() (at HotUpdateScripts/UI/LoginGame/LoginGame.cs:35) IL_004b: call System.Byte[] Nino.Serialization.Serializer::Serialize(!!0,Nino.Serialization.CompressOption) UI.LoginGame.LoginGame.Start() (at HotUpdateScripts/UI/LoginGame/LoginGame.cs:35) UnityEngine.DebugLogHandler:LogException(Exception, Object) JEngine.Core.Logger:LogException(Exception, Object) (at Assets/Dependencies/JEngine/Core/Logger/LogHandler.cs:201) UnityEngine.Debug:LogException(Exception) JEngine.Core.LifeCycleMgr:ExecuteItems(List1, Boolean, Func2) (at Assets/Dependencies/JEngine/Core/Manager/LifeCycleMgr.cs:326) JEngine.Core.LifeCycleMgr:LateUpdate() (at Assets/Dependencies/JEngine/Core/Manager/LifeCycleMgr.cs:485)