Zeres Plugin Library New! Access
: Provides a unified way to output debug information to the console, making troubleshooting easier for both developers and users. Implementation for Developers For a plugin to leverage ZPL, it typically checks for the library's presence upon initialization. If the library is missing, the plugin can prompt the user to download it. This modular approach ensures that the "heavy lifting" of the code is centralized in one frequently updated library rather than being duplicated in every individual plugin. Impact on the BetterDiscord Ecosystem ZeresPluginLibrary has become a de facto standard. Its widespread adoption means that: Maintenance is Easier
The Zeres Plugin Library: A Complete Guide to .NET Plugins Introduction In modern software development, extensibility is key. Allowing third-party developers to extend your application without touching its core code is a hallmark of robust architecture. The Zeres Plugin Library (often referred to as ZeresPluginLibrary ) is a powerful, open-source .NET library designed specifically to simplify the creation, loading, and management of plugins in C# and VB.NET applications. Originally gaining popularity within the Discord bot development community (specifically for DiscordChatExporter and similar tools), the library has evolved into a general-purpose framework for any .NET application needing modular plugin support. What is the Zeres Plugin Library? The Zeres Plugin Library provides a set of abstract classes, interfaces, and helper utilities that handle the heavy lifting of plugin architecture:
Dynamic assembly loading from external DLLs Dependency resolution between plugins Version compatibility checking Event-driven communication between the host and plugins Safe AppDomain isolation (optional)
Unlike building a plugin system from scratch—which involves reflection, assembly scanning, and conflict management—Zeres gives you a production-ready foundation. Key Features | Feature | Description | |---------|-------------| | Auto-discovery | Scans specified folders for valid plugin assemblies | | Dependency injection | Plugins can declare required host services | | Version constraints | Plugins specify which host versions they support | | Lifecycle hooks | OnLoad , OnUnload , OnEnable , OnDisable methods | | Cross-plugin communication | Publish/subscribe event bus | | No-touch deployment | Add/remove plugins while host is running | Core Components 1. PluginBase (Abstract Class) Every plugin must inherit from this. It provides the essential lifecycle methods: public abstract class PluginBase { public virtual void OnLoad(IPluginHost host) { } public virtual void OnEnable() { } public virtual void OnDisable() { } public virtual void OnUnload() { } } zeres plugin library
2. IPluginHost Interface The host application implements this to expose services to plugins (logging, configuration, API access). 3. PluginAttribute Metadata for plugin identification: [Plugin("My Plugin", Author = "Jane", Version = "1.0.0")] public class MyPlugin : PluginBase { ... }
4. PluginLoader The main engine that discovers, validates, and instantiates plugins. Getting Started (Step-by-Step) Step 1: Install the Library Via NuGet Package Manager: Install-Package ZeresPluginLibrary
Or via .NET CLI: dotnet add package ZeresPluginLibrary : Provides a unified way to output debug
Step 2: Define the Host Interface Create a shared interface that both host and plugins reference: // SharedContracts.dll public interface IAppHost { void Log(string message); string GetConfig(string key); }
Step 3: Implement the Host using ZeresPluginLibrary; public class MyApplication : IAppHost { private PluginLoader loader; public void Start() { loader = new PluginLoader("./Plugins", this); loader.LoadPlugins();
foreach (var plugin in loader.Plugins) { plugin.OnEnable(); } } PluginLoader The main engine that discovers
public void Log(string message) => Console.WriteLine($"[HOST] {message}"); public string GetConfig(string key) => ConfigurationManager.AppSettings[key];
}