EXILED supports reloading plugin assemblies at runtime using the reload plugins command in RemoteAdmin/ServerConsole without restarting the server. To support this safely, developers must follow specific cleanup rules to prevent memory leaks or conflicting logic.
Developer Requirements for Dynamic Updates
When a plugin is reloaded, EXILED calls OnDisabled(), then OnReloaded(), loads the new assembly, and finally calls OnEnabled(). To prevent issues, your plugin must do the following in OnDisabled() or OnReloaded():
- Unsubscribe from Events: Unhook all events the plugin is subscribed to.
- Clean up Harmony Patches: If using custom Harmony patches, use a unique instance name and call
UnPatchAll() on that instance. - Stop Coroutines: Kill all MEC coroutines started by the plugin.
Assembly Naming (Crucial)
Because of the Global Assembly Cache (GAC), if you replace an assembly with one of the same name, the old code will still run alongside the new code.
- To support dynamic updates: You must change the Assembly Name in your build settings for every new version. Simply renaming the file is not enough.
- If you do NOT support dynamic updates: Keep the Assembly Name constant, but inform server hosts that they must perform a full server restart to update your plugin.