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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:20:49+00:00 2026-05-10T18:20:49+00:00

I need to create a configuration section, that is able to store key-value pairs

  • 0

I need to create a configuration section, that is able to store key-value pairs in an app.config file and the key-value pairs can be added runtime regardless of their type. It is also important that the value keeps its original type. I need to extend the following interface

public interface IPreferencesBackend {     bool TryGet<T>(string key, out T value);     bool TrySet<T>(string key, T value);  } 

At runtime, I can say something like:

My.Foo.Data data = new My.Foo.Data('blabla'); Pref pref = new Preferences(); pref.TrySet('foo.data', data);  pref.Save();  My.Foo.Data date = new My.Foo.Data(); pref.TryGet('foo.data', out data); 

I tried with System.Configuration.Configuration.AppSettings, but the problem with that that it is storing the key-value pairs in a string array.

What I need is to have an implementation of System.Configuration.ConfigurationSection, where I can control the how the individual setting is serialized. I noticed that the settings generated by Visual Studio kind of do this. It is using reflection to create all the setting keys. what I need is to do this runtime and dynamically.

[System.Configuration.UserScopedSettingAttribute()] [System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.Configuration.DefaultSettingValueAttribute('2008-09-24')] public global::System.DateTime DateTime {    get {         return ((global::System.DateTime)(this['DateTime']));        }    set {         this['DateTime'] = value;        }  } 
  • 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. 2026-05-10T18:20:49+00:00Added an answer on May 10, 2026 at 6:20 pm

    I found two great articles on codeproject.com that are explaining these issues in great detail.

    Unraveling the Mysteries of .NET 2.0 Configuration http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration.aspx

    User Settings Applied http://www.codeproject.com/KB/dotnet/user_settings.aspx?display=PrintAll&fid=1286606&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2647446&fr=26

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

Sidebar

Ask A Question

Stats

  • Questions 106k
  • Answers 106k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Is it read-write or read-only? If it's read-only it probably… May 11, 2026 at 8:53 pm
  • Editorial Team
    Editorial Team added an answer Brute force: Attach handler to each PropertyChanged event for each… May 11, 2026 at 8:53 pm
  • Editorial Team
    Editorial Team added an answer Get a copy of Working Effectively with Legacy Code by… May 11, 2026 at 8:53 pm

Related Questions

I have a system that filters template files through erb. Using convention over configuration,
I'm really new to .NET, and I still didn't get the hang about how
I would like to store a collection of custom objects in a user.config file
This is probably one of the most common tasks / problems when programming; You

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.