I'm writing an application that includes a plugin system in a different assembly.
The problem is that the plugin system needs to get application settings from the main app (like the directory to look for plugins).
How is this done, or am I going about this the wrong way?
Edit: I was encouraged to add some details about how the plugin system works. I haven't completely worked that out and I've only just begun implementing it, but I basically went by this article.
User-scope settings are stored in the user's appdata folder. Application-scope settings are stored in C:\Users\My Name\AppData\Local\My_Company\. If your settings file doesn't contain any Application-scope settings, you won't have a company folder.
Settings. settings is located in the My Project folder for Visual Basic projects and in the Properties folder for Visual C# projects. The Project Designer then searches for other settings files in the project's root folder. Therefore, you should put your custom settings file there.
An application configuration file is an XML file used to control assembly binding. It can redirect an application from using one version of a side-by-side assembly to another version of the same assembly. This is called per-application configuration.
By adding an application configuration file (app. config file) to a C# project, you can customize how the common language runtime locates and loads assembly files. For more information about application configuration files, see How the runtime locates assemblies (. NET Framework).
Let the main application get the plugin directory from the application settings and push it into the plugin system.
Perhaps you could insert the configuration as an argument when creating the plugin?
//Get the configuration for the current appDomain
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//Create the plugin, and pass in the configuration
IPlugin myPlugin = new AlfaPlugin(config);
You'll probably need a reference to the System.Configuration assembly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With