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 6703905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:13:36+00:00 2026-05-26T07:13:36+00:00

Perhaps this question has been asked before in a different way, but I haven’t

  • 0

Perhaps this question has been asked before in a different way, but I haven’t been able to find it.

I have one or more plugin adapter assemblies in my application all having the type IPlugin, for instance. Each adapter has its own settings structures stored in a common directory. Whether they are stored in one contiguous file or in separate ones doesn’t matter. Each adapter can have one or more settings associated with it. The settings will have both a name and the Plugin it will be used for.
How would I create such a configuration system using the following requirements:

  1. I want to use .NETs built in
    settings system and avoid writing
    one from scratch
  2. The host application will be
    responsible for locating the plugin
    settings and passing it to the
    plugin
  3. Each plugin will be
    responsible for reading and writing
    its own settings to separate
    concerns. The host application
    should call Plugin.Save(thePath) and
    it does its thing.
  4. All settings are user scoped

So far, I realize that I would need to write my own SettingsProvider, but the provider seems to work in isolation in that there’s no way to pass it parameters such as the path of the plugin directory and the name of the settings. All of the example code I’ve seen has the provider getting the data from the runtime environment.

  • 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-05-26T07:13:37+00:00Added an answer on May 26, 2026 at 7:13 am

    The plugins in your example would new up a PluginSettings and then call into it like this:

    PluginSettings["age"] = "5";
    int age;
    if (int.TryParse(PluginSettings["age"], out age)
    {
    
    }
    else
    {
    }
    

    Code for PluginSettings:

    using System.Configuration;
    using System.Xml;
    
    public sealed class PluginSettings
    {
        public string this[string propertyName]
        {
            get
            {
                var store = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                UserSettingsGroup values = (UserSettingsGroup)store.SectionGroups["userSettings"];
                if (values == null)
                {
                    return null;
                }
                ClientSettingsSection myValues = (ClientSettingsSection)values.Sections[typeof(DebuggerSettings).FullName];
                if (myValues == null)
                {
                    return null;
                }
                SettingElement setting = myValues.Settings.Get(propertyName);
                if (setting == null)
                {
                    return null;
                }
                string returnValue = setting.Value.ValueXml.InnerText;
                return returnValue;
            }
            set
            {
                var store = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                UserSettingsGroup addSectionGroup = (UserSettingsGroup)store.SectionGroups["userSettings"];
                if (addSectionGroup == null)
                {
                    addSectionGroup = new UserSettingsGroup();
                    store.SectionGroups.Add("userSettings",addSectionGroup);
                }
                string sectionName = (typeof(DebuggerSettings).FullName);
                ClientSettingsSection clientSettingsSection = (ClientSettingsSection)addSectionGroup.Sections[sectionName];
                if (clientSettingsSection == null)
                {
                    clientSettingsSection = new ClientSettingsSection();
                    clientSettingsSection.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser;
                    addSectionGroup.Sections.Add(sectionName, clientSettingsSection);
                }
                SettingElement addMe = new SettingElement(propertyName, SettingsSerializeAs.String);
                XmlElement element = new XmlDocument().CreateElement("value");
                element.InnerText = value;
                addMe.Value.ValueXml = element;
                clientSettingsSection.Settings.Add(addMe);
    
                store.Save();
            }
        }
    }
    

    I had the same issue and blogged about it.

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

Sidebar

Related Questions

This question has been asked before perhaps multiple times, but I can't get the
Perhaps this question has been asked elsewhere, but I'm unable to find it. With
I know this question has been asked before but I have a design question
I know this sort of question has been asked before , but I still
I believe that this question has been asked in a few different forms, but
Apologies if this question has been asked already, but suppose we have this code
I haven't found an answer to this particular question; perhaps there isn't one. But
I have tried contacting tech support with this question, but it has been over
Ok, I know this has been asked a thousand times before, but no conclusive
I'm new to this, so sorry if my question has been asked before. I

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.