We are introducing a plug and play module for our application, where the user can load and unload the required class library at runtime. So I decided to use MEF and shadow copy of class libraries.
Here, each class library can have different configuration properties that must be set by the user. My main application is not aware of the configurations present in the class library.
Now the problem is that I am trying to transfer the application configuration file loaded by the class library from one application domain to another.
Without MEF, I just returned Settings.Default from the class library, and I used it in our main application to edit the settings. With MEF and shadow copy, this doesn't seem to work because
- The type of object must be known to both parties.
- I cannot implement
MarshalByRefObject in the settings file, since the settings file already extends ApplicationSettingsBase , which is an abstract class, and C # does not support multiple inheritance.
I am currently creating a class that contains all properties as a string and creates a GUI in my main application based on this class content.
public class ExtensionModuleConfiguration : MarshalByRefObject { public string Name { get; set; } public string Value { get; set; } public List<string> Options { get; set; } public UIElements ToolUIElement { get; set; } } public enum UIElements { ComboBox, TextBox }
I have to say that this is not the best solution. Can anyone suggest a better way to set class library configurations in MEF?
source share