Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

真机报can not load type #313

Open
ASD12138 opened this issue May 12, 2021 · 11 comments
Open

真机报can not load type #313

ASD12138 opened this issue May 12, 2021 · 11 comments

Comments

@ASD12138
Copy link

编辑器上测试没问题,打了安卓包在手机上运行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

@chexiongsheng
Copy link
Collaborator

你生成补丁的环境和手机上的.net不一样。生成补丁用的是netstandard2.0,手机不是

@ASD12138
Copy link
Author

我打包用的Unity和生成补丁文件的Unity设置的.net都是2.0版本的,另一个项目用的2019.4的Unity版本同样用2.0来生成补丁和打包测试就没有报这种问题,用的同一台手机测试

@chexiongsheng
Copy link
Collaborator

看你说得就不太专业
.net 2.0 != netstandard2.0

netstandard2.0 比.net 4.0版本都要高很多。

@ASD12138
Copy link
Author

我用来打包和生成补丁的Unity的设置都是默认的,同一份配置,应该都是.NET Standard 2.0

@chexiongsheng
Copy link
Collaborator

或者就是被剪裁了

@ASD12138
Copy link
Author

以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,如果有人遇到同类问题希望这些能给到你一点帮助

@JourneyHans
Copy link
Contributor

请问下如何修改managedStrippingLevel的设置呢?我用的Unity2021,也出现这个问题了。Unity里面不是只有这几个选项吗?怎么改到 .net 版本的呢?

image

@Eric1042017370
Copy link

Eric1042017370 commented Aug 2, 2022 via email

@JourneyHans
Copy link
Contributor

我以为可以针对2.1不裁剪呢,目前我也是改成先不用2.1了

@luzay
Copy link

luzay commented Mar 12, 2024

unity 2021.3.21遇到相同问题
是只有把api compatibility level设置成.NET Framework这一种办法么?
.NET Standard 2.1的情况下有办法支持么?

补充:设置成不裁切没有用,只有设置成.NET Framework才行

@sableangle
Copy link

sableangle commented Mar 21, 2024

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 是可以的 請試試看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants