Skip to content

[Bug]: Harmony patches fail even with empty patch body #1182

Description

@JW11-modder

All of the following criteria must be met

  • All Requirements must be installed.
  • Changed the title so that it doesn't just says "[Bug]: "
  • I have searched the GitHub issues for my bug, even in the closed issues.

All of the following are optional to answer

  • Tried reinstalling the Game.
  • Tried reinstalling MelonLoader.
  • Tried restarting PC.

Describe the issue.

When the game thies to invoke patched method, it fails with "Object reference not set to an instance of an object" error, even if patch body is empty.

Example:

[HarmonyPatch(typeof(ShieldUnitsManager), nameof(ShieldUnitsManager.DealDamageToShields))] class ShieldUnitsManagerPatch1 { static bool Prefix() { return true; } }

leads to error in logs:

[20:26:33.311] [ERROR] [Il2CppInterop] During invoking native->managed trampoline System.NullReferenceException: Object reference not set to an instance of an object. at (il2cpp -> managed) DealDamageToShields(IntPtr , Single , IntPtr , Single& , Il2CppMethodInfo* )

This error remains the same with any type of patch - Prefix, Postfix, Transplier.

I'm using current nightly build of MelonLoader, Unity version 6000.3.9f1

Full log included

Latest.log

Did you attach your log file?

Yes, I attached my log file to the text box above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug / IssueSomething isn't workingWork-in-ProgressThis issue or pull request is being worked on currently

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions