MEF parts configuration, where to store?

In ASP.NET, .NET 4.0, MEFI put all the pieces in a folder and import them via DirectoryCatalog. All perfectly. Some of them have related configurations. I do not want to put them in web.config. Perhaps a good approach is to have a file confignext to the part with an append .configto the end.

What is the best way to store part configuration?

+5
source share
1 answer

I was able to create a separate configuration file for each DLL and successfully read the keys. But when I tried to create a custom configuration section, I could not read the DLL from the application configuration. He always wanted to read from EEF Consumer exe.

Here is the code to read from appluted dll application configuration

var appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location); 
    return appConfig.AppSettings.Settings["SomeKeyName"].Value;  

Since I was unable to read from the custom configuration section, I ended up using xml and serializing the custom configuration section for the object. Since you just get information about the mail server, you will not have problems using app.config.

+3
source

All Articles