Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8720237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:59:23+00:00 2026-06-13T06:59:23+00:00

I would like to access the values in the ConfigurationManager.AppSettings object from a MEF

  • 0

I would like to access the values in the ConfigurationManager.AppSettings object from a MEF plugin which has its own app.config file.

However, the keys from the app.config file are not present in AppSettings after the plugin is loaded.
The keys from the application loading the plugin are still present.

I noticed that using a Settings.settings file allows this behaviour, via the app.config file, so the file must be being loaded somehow.

My plugin looks like:

[Export(IPlugin)]
public class Plugin
{
    public Plugin()
    {
        // reads successfully from app.config via Settings object
        var value1 = Settings.Default["Key1"];

        // returns null from app.config via ConfigurationManager
        var value1 = ConfigurationManager.AppSettings["Key2"]
    }
}

The app.config looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="applicationSettings" type="..." >
      <section name="Plugin.Settings" type="..." />
    </sectionGroup>
  </configSections>

  <appSettings>
    <add key="Key2" value="Fails" />
  </appSettings>

  <applicationSettings>
    <Plugin.Settings>
      <setting name="Key1" serializeAs="String">
        <value>Works</value>
      </setting>
    </Plugin.Settings>
  </applicationSettings>
</configuration>

I can manually load the app.config file with:

var config = ConfigurationManager.OpenExeConfiguration("Plugin.dll");
var value = AppSettings.Settings["Key2"].Value

but this seems more like a workaround than a solution.

Is there a way to access a MEF plugin’s <appSettings> directly, from inside the plugin?
If not, what is recommended?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:59:25+00:00Added an answer on June 13, 2026 at 6:59 am

    By default the ConfigurationManager loads the .config for the entry assembly, i.e. the assembly that started the currently executing process.

    The correct way to do this would be something like this:

    [Export(IPlugin)]
    public class Plugin
    {
        public Plugin()
        {
            var config = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
            var value = config.AppSettings.Settings["Key2"].Value;
        }
    }
    

    This would make the plugin automatically open the .config for the DLL it was compiled in, and fetch values from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use ConfigurationManager to access some string values from a static
I would like to access some values from a CFMutableDictionaryRef and then do some
I would like to access hashmap set of values created in main class from
I am working on a Universal app & would like to access the values
I would like to know if there is some way to access the values
I would like to set some values in context.xml file and access the same
I have an IEnumerable object. I would like to access based on index for
i would like to access an variable, which is in an class (not as
Basically I would like to access the same Rails app in production or environment
I would like to create one class which holds some key values of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.