Skip to content

InvalidProgramException when MenuLib patches MenuScrollBox.Update (BepInEx 5.4.2100, game v0.3.0) #16

@P-C-LION

Description

@P-C-LION

Describe the bug

When using MenuLib with the current game version v0.3.0 under BepInExPack v5.4.2100, the game throws an InvalidProgramException related to an invalid IL instruction in a dynamically patched method.

Error message

[Error  : Unity Log] InvalidProgramException: Invalid IL code in (wrapper dynamic-method)
MenuScrollBox:DMD<MenuScrollBox::Update> (MenuScrollBox): IL_0140: bne.un IL_0154

Stack trace

System.RuntimeMethodHandle.GetFunctionPointer()
MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform.GetFunctionPointer()
...
MenuLib.Entry.Awake () (at <d791593245e64c2f8016f90632f17190>:0)
UnityEngine.GameObject:AddComponent(Type)
BepInEx.Bootstrap.Chainloader:Start()

Steps to reproduce

Install BepInExPack v5.4.2100

Install MenuLib

Launch the game (v0.3.0)

Observe that the game crashes or logs InvalidProgramException on startup

Expected behavior

The game should start normally without an Invalid IL code error.

Environment

Game version: v0.3.0

BepInEx version: 5.4.2100

MenuLib version: v2.5.0

OS: Windows 11

Additional context

It seems that MenuLib is attempting to IL-hook MenuScrollBox.Update(), but the target method’s structure might have changed in game v0.3.0, causing invalid IL generation (bne.un IL_0154).
Disabling MenuLib removes the error completely.
Thank you for your work on this mod! MenuLib is great, just reporting this so it can stay compatible with the latest game update 😊

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions