Open 6thmoon opened 1 year ago
Any comment? It doesn't come up often, but there have been a few users affected by this.
I just encountered this issue when running two Lethal Company mods together:
https://thunderstore.io/c/lethal-company/p/Zaggy1024/TwoRadarMaps/ https://thunderstore.io/c/lethal-company/p/SylviBlossom/TerminalConflictFix/
It appears that
ILPatternMatchingExt
expectsILLabel
as branch operand but instead receivesInstruction
after running the Transpiler. Here is the stack trace displayed in the BepInEx console:Click to expand...
``` [Error : HarmonyX] Failed to patch void Test.Plugin::Example(): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Specified cast is not valid. at MonoMod.Cil.ILPatternMatchingExt.MatchBr (Mono.Cecil.Cil.Instruction instr, MonoMod.Cil.ILLabel& value) [0x0002b] in <6733e342b5b549bba815373898724469>:IL_002B at Test.Plugin+<>c.BepInEx package used was the latest version -
5.4.21
, running on Windows 10. I tried a few different combinations of .NET framework and Unity game engine with the same results. The following code illustrates a simple way to reproduce this error:Of course, this is a rather contrived example. The real situation where this may arise is when two separate plugins are attempting to patch the same method in game - one using ILManipulator, while the other leverages a Transpiler. Interestingly enough, the issue did not occur upon replacing the
HarmonyILManipulator
with an identical MonoMod IL hook.