focus-creative-games / hybridclr

HybridCLR是一个特性完整、零成本、高性能、低内存的Unity全平台原生c#热更新解决方案。 HybridCLR is a fully featured, zero-cost, high-performance, low-memory solution for Unity's all-platform native c# hotupdate.
https://code-philosophy.com/
MIT License
6.51k stars 656 forks source link

ExecutionEngineException: System.Collections.Generic.Stack`1::.ctor method body is null. not support external method currently. #25

Closed Jihuihu closed 2 years ago

Jihuihu commented 2 years ago

错误提示为 external相关,但是代码中未涉及,稳定复现 hybridclr_trial 工程中,加入部分代码如下:

Unity Editor版本: 2021.3.11f1(M1版本) image 操作系统: MacOS Ventura 13.0 BuildTarget:IOS hybridclr_trial 的版本号 0.9

public class HotUpdateMain : MonoBehaviour {

public string text;

// Start is called before the first frame update
void Start()
{
    Debug.Log("这个热更新脚本挂载在prefab上,打包2222222成ab。通过从ab中实例化prefab成功还原");
    Debug.LogFormat("hello, {0}.", text);

    gameObject.AddComponent<CreateByCode>();

    Debug.Log("=======看到此条日志代表你成功运行2222222了示例项目的热更新代码=======");
    UpdateContext test = new UpdateContext();
    Debug.Log("=======看到此条日志代表你成功运行3333333了示例项目的热更新代码=======");
}

}

public class UpdateContext { public struct ClipInfo { public Rect rect; public Vector4 clipBox; public bool soft; public Vector4 softness; //left-top-right-bottom public uint clipId; public int rectMaskDepth; public int referenceValue; public bool reversed; }

public UpdateContext()
{
    _clipStack = new Stack<ClipInfo>();
}

Stack<ClipInfo> _clipStack;
public static UpdateContext current;

}

运行期Log: LoadMetadataForAOTAssembly:System.Core.dll. mode:SuperSet ret:OK LoadDll:LoadMetadataForAOTAssemblies() LoadDll:StartGame()

d__7:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) 这个热更新脚本挂载在prefab上,打包2222222成ab。通过从ab中实例化prefab成功还原 UnityEngine.StackTraceUtility:ExtractStackTrace() hello, HybridCLR. UnityEngine.StackTraceUtility:ExtractStackTrace() =======看到此条日志代表你成功运行2222222了示例项目的热更新代码======= UnityEngine.StackTraceUtility:ExtractStackTrace() ExecutionEngineException: System.Collections.Generic.Stack`1::.ctor method body is null. not support external method currently. at UpdateContext..ctor () [0x00000] in <00000000000000000000000000000000>:0 at HotUpdateMain.Start () [0x00000] in <00000000000000000000000000000000>:0 这个脚本是通过代码AddComponent直接创建的3333333 UnityEngine.StackTraceUtility:ExtractStackTrace()
pirunxi commented 2 years ago

我们使用你的测试代码,在最新代码上未复现这个问题,无论用裁剪后的dll还是原始dll。能否再确认一下?

32wufan commented 2 years ago

unity editor:2020.3.33f1c1 操作系统:win10专业版 windows64 hybridclr_trial 的版本号 0.9 image image 问题情况: 正常打包热更新dll,运行无报错,但有段代码(自己封装的数据管理模块),无法执行,也没有任何报错,之前数据接口继承了IDispose,后面把这个接口删除了,重新打包的,仍然无法执行