Skip to content

AccessTools.Field: Could not find field for type System.Diagnostics.StackFrame and name methodAddress #755

@kmai-universe

Description

@kmai-universe

Hi,

I'm trying to use Harmony to patch a Unity project from 2016 which uses MONO 2.0. I use the .NET 3.5 version of Harmony 2.4.2.0 but keep getting this error on any patch method that i try to implement:

`

Harmony id=harmony.vrcoaster, version=2.4.2.0, location=\Managed\0Harmony.dll, env/clr=2.0.50727.1433, platform=Win32NT

AccessTools.Method: Could not find method for type System.Exception and name PrepForRemoting and parameters

Started from static System.Void Universe.IT.Modding.Loader::OnLoad(), location \Managed\vrcoaster-mod.dll

At 2026-01-22 08.49.21

AccessTools.Field: Could not find field for type System.Diagnostics.StackFrame and name methodAddress

Patch: System.Void Smaaash.GeneralOperations::LaunchAppropriate()

Replacement: static System.Void Smaaash.GeneralOperations::Smaaash.GeneralOperations.LaunchAppropriate_Patch1(Smaaash.GeneralOperations this)

IL_0000: // start original
IL_0000: ldsfld Smaaash.Hardware Smaaash.Grid::hardware
IL_0005: ldfld Smaaash.WhatAmI Smaaash.Hardware::whatAmI
IL_000A: ldc.i4.1
IL_000B: bne.un => Label0
IL_0010: ldstr "DrawKiosk"
IL_0015: call static System.Void UnityEngine.Application::LoadLevel(System.String name)
IL_001A: br => Label3
IL_001F: Label0
IL_001F: ldsfld Smaaash.Hardware Smaaash.Grid::hardware
IL_0024: ldfld Smaaash.WhatAmI Smaaash.Hardware::whatAmI
IL_0029: ldc.i4.2
IL_002A: bne.un => Label1
IL_002F: ldstr "OperatorKiosk"
IL_0034: call static System.Void UnityEngine.Application::LoadLevel(System.String name)
IL_0039: br => Label4
IL_003E: Label1
IL_003E: ldsfld Smaaash.Hardware Smaaash.Grid::hardware
IL_0043: ldfld Smaaash.WhatAmI Smaaash.Hardware::whatAmI
IL_0048: brtrue => Label2
IL_004D: ldstr "Oculus"
IL_0052: call static System.Void UnityEngine.Application::LoadLevel(System.String name)
IL_0057: br => Label5
IL_005C: Label2
IL_005C: ldarg.0
IL_005D: ldfld UnityEngine.UI.Text Smaaash.GeneralOperations::whoMsg
IL_0062: ldstr "Development Error?\nStrange problem with ID Files."
IL_0067: callvirt virtual System.Void UnityEngine.UI.Text::set_text(System.String value)
IL_006C: // end original
IL_006C: Label3
IL_006C: Label4
IL_006C: Label5
IL_006C: nop
IL_006D: call static System.Void Universe.IT.Modding.GeneralOperations_LaunchAppropriate_patch::Postfix()
IL_0072: ret
DONE
`

It does not matter what method i try to patch, they will all crash the mod with the same "AccessTools.Field: Could not find field for type System.Diagnostics.StackFrame and name methodAddress".

My project is set to .NET framework 4.7.2

Is it just not possible to use Harmony 2 for old unity project running MONO 2.0?

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