真机报can not load type
编辑器上测试没问题,打了安卓包在手机上运行PatchManager.Load 就会报can not load type,不管是修复的哪个函数都会报类似这种can not load type [System.Collections.IEnumerator, netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51],括号里面的参数是根据我修复函数的参数来的,这个是修复没参数的函数时报的
还有类似这种的can not load type [System.Action`2[[UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null],[UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]
有没有遇到同类的问题,没啥头绪,用的2020.3版本的Unity
你生成补丁的环境和手机上的.net不一样。生成补丁用的是netstandard2.0,手机不是
我打包用的Unity和生成补丁文件的Unity设置的.net都是2.0版本的,另一个项目用的2019.4的Unity版本同样用2.0来生成补丁和打包测试就没有报这种问题,用的同一台手机测试
看你说得就不太专业 .net 2.0 != netstandard2.0
netstandard2.0 比.net 4.0版本都要高很多。
我用来打包和生成补丁的Unity的设置都是默认的,同一份配置,应该都是.NET Standard 2.0
或者就是被剪裁了
以can not load type[System.string, netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]为例Unity2020.3的项目里面ApiCompatibilityLevel如果设置的是standard 2.0,那参数string就会是netstandard, Version=2.0.0.0的,在 Unity项目如果开启了managedStrippingLevel,会减小包的体积裁剪了一些代码,netstandard.dll会被删除,从而导致找不到对应的string类型,2019.4的版本不管ApiCompatibilityLevel怎么设置,用的都是 mscorlib, Version=4.0.0.0的,而mscorlib.dll没有因为managedStrippingLevel的设置而删除,所以之前2019.4版本的项目没发现问题,由于时间原因目前的处理是将2020.3的managedStrippingLevel改到.net 4,如果有人遇到同类问题希望这些能给到你一点帮助
请问下如何修改managedStrippingLevel的设置呢?我用的Unity2021,也出现这个问题了。Unity里面不是只有这几个选项吗?怎么改到 .net 版本的呢?

切换到.net 版本是在PlayerSettings里面有一个: api compatibility level* 里,选择.net4x。
------------------ 原始邮件 ------------------ 发件人: "Tencent/InjectFix" @.>; 发送时间: 2022年8月1日(星期一) 下午4:51 @.>; @.***>; 主题: Re: [Tencent/InjectFix] 真机报can not load type (#313)
请问下如何修改managedStrippingLevel的设置呢?我用的Unity2021,也出现这个问题了。Unity里面不是只有这几个选项吗?怎么改到 .net 版本的呢?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>
我以为可以针对2.1不裁剪呢,目前我也是改成先不用2.1了
unity 2021.3.21遇到相同问题 是只有把api compatibility level设置成.NET Framework这一种办法么? .NET Standard 2.1的情况下有办法支持么?
补充:设置成不裁切没有用,只有设置成.NET Framework才行
link.xml
<linker>
<assembly fullname="IFix.Core" preserve="all" />
<assembly fullname="Assembly-CSharp">
<type fullname="IFIX.WrappersManagerImpl" preserve="all" />
<type fullname="IFix.ILFixInterfaceBridge" preserve="all" />
<type fullname="IFix.IDMAP0" preserve="all" />
</assembly>
<assembly fullname="UnityEngine" preserve="all" />
<assembly fullname="UnityEngine.UI" preserve="all" />
<assembly fullname="netstandard" preserve="all"/>
</linker>
我們嘗試過使用 link.xml 來避免 netstandard 被剪裁
在 2021.3 是可以的 請試試看