DetourContext Dispose Fix

v1.0.9·Updated 2026-05-02

A BepInEx patcher to fix MonoMod.RuntimeDetour's DetourContext.Dispose not working.

About this mod Author’s original text

DetourContext.Dispose Fix

This BepInEx Patcher applies the fix from Fix DetourContext.Dispose #102, which makes MonoMod.RuntimeDetour.DetourContext.Dispose work properly. This is only useful if you are using a version of MonoMod.RuntimeDetour which doesn't have this patch.

If the patcher doesn't find the IL code it is looking to patch, it will print Nothing to patch. to the BepInEx console. If this is the case, this patcher isn't needed.

Why This Matters

If you are using DetourContext, e.g.:

using(new DetourContext(){ Priority = 100 })

{

On.StartOfRound.Awake += Hook_2;

}

On.StartOfRound.Awake += Hook_1;

The DetourContext wouldn't dispose of itself, and Hook_1 would run before Hook_2 because it also got applied to it.

With this patcher, the DetourContext will dispose of itself and Hook_2 will run before Hook_1 like it should.

Install & use Install: BepInEx plugin

  1. The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
  2. Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
  3. Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
  4. Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.

Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.

Dependencies

Install these first, or the mod will not work:

BepInEx-BepInExPack

File & checksum

Filename
DetourContext_Dispose_Fix-1.0.9.zip
File size
28.9 KiB