Skip to content

Registering commands with Meta.Load does not unregister them when the plugin is unloaded #254

Open

Description

@AutumnRivers

What a mouthful.

What Happens

Registering a command with Pathfinder.Meta.Load.Command will not unregister it when the plugin is unloaded, leading to an error when trying to load the plugin again.

Steps to Reproduce

  1. Create a basic Hacknet plugin.
  2. Create a command, and register it with [Pathfinder.Meta.Load.Command].
  3. Load the plugin as an extension plugin.
  4. Load the extension, then exit it. (You don't need to create an account)
  5. Go back to the extension, and observe the error in the console.

Troubleshooting Attempts

Not much to do, unfortunately. Exiting the game completely fixes this.

Relevant Logs

Log is very messy, so I'll just post the relevant portion:

[Info   :   BepInEx] 2 plugins to load
[Info   :   BepInEx] Loading [Stuxnet 2.0.0]
[Info   :  HarmonyX] ### Harmony id=BepInEx.Plugin.autumnrivers.stuxnet, version=2.5.5.0, location=M:\SteamLibrary\steamapps\common\Hacknet\BepInEx\core\0Harmony.dll, env/clr=4.0.30319.42000, platform=Win32NT, ptrsize:runtime/env=4/Bits64, Windows
### Started from void BepInEx.Hacknet.HacknetPlugin::.ctor(), location M:\SteamLibrary\steamapps\common\Hacknet\BepInEx\core\BepInEx.Hacknet.dll
### At 2025-08-21 11.51.03
[Error  :   BepInEx] Error loading [Stuxnet 2.0.0]: System.ArgumentException: Command messenger has already been registered!
Parameter name: commandName
   at Pathfinder.Command.CommandManager.RegisterCommand(String commandName, Action`2 handler, Boolean addAutocomplete, Boolean caseSensitive) IL<0x0052>
   at Pathfinder.Meta.Load.CommandAttribute.CallOn(HacknetPlugin plugin, MemberInfo targettedInfo) IL<0x0031>
   at Pathfinder.Meta.Load.AttributeManager.ReadAttributesOnType(HacknetPlugin plugin, Type type) IL<0x008C>
   at Pathfinder.Meta.Load.AttributeManager.ReadAttributesFor(HacknetPlugin plugin) IL<0x0046>
   at DMD<BepInEx.Hacknet.HacknetChainloader::LoadPlugin>(HacknetChainloader this, PluginInfo pluginInfo, Assembly pluginAssembly) IL<0xFFFFFFFF>
   at DMD<BepInEx.Bootstrap.BaseChainloader`1[[BepInEx.Hacknet.HacknetPlugin, BepInEx.Hacknet, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null]]::Execute>(BaseChainloader`1 this) IL<0xFFFFFFFF>
[Warning:   BepInEx] Skipping [Stuxnet.Audio 0.1.0] because it has a dependency that was not loaded. See previous errors for details.
[Message:   BepInEx] Chainloader startup complete
New Game Detected!

Additional Information

N/A

Activity

  1. AutumnRivers commented on Sep 9, 2025

    @AutumnRivers
    CollaboratorAuthor

    UPDATE: This also seems to happen with Conditions and Actions if there's several being registered with the attribute.

  2. SoundOfScooting commented on Sep 10, 2025

    @SoundOfScooting
    Contributor

    Actions and conditions aren't using GetCallingAssembly(), so that would appear to be a different issue.

  3. AutumnRivers commented on Sep 10, 2025

    @AutumnRivers
    CollaboratorAuthor

    I believe it is a different issue, Actions and Conditionals error out with "An item with that key already exists"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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