Closed r-Lxd closed 1 year ago
This isn't an issue with Il2CppInterop, we assume that there will be one instance of Il2Cppmscorlib.dll
present in the AppDomain. Swapping Single
for First
only moves the issue to another place and you might run into a problem where something references the 1st loaded Il2Cppmscorlib but another references the 2nd one.
In the case of UniverseLib, it's a known issue with UniverseLib that it loads multiple new AssemblyLoadContexts.
If your plugin is using Assembly.LoadFile
, you should switch to Assembly.LoadFrom
to ensure you are loading the assembly in the default context which would prevent multiple instances being present.
Depending on what game you're trying to mod (I was doing this on Sons of the Forest), this Line will throw a
InvalidOperationException (Sequence contains more than one matching element)
errorThis causes old libraries such as UniverseLib to break.
I fixed this by manually changing
Select
toFirstOrDefault
in DnSpy