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

  • Home
  • SEARCH
  • 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 4531886
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T13:57:35+00:00 2026-05-21T13:57:35+00:00

I have following issue: I’m introducing new feature into application (run as Windows Service)

  • 0

I have following issue: I’m introducing new feature into application (run as Windows Service) and I would like to have that new feature controlled (on/off) using some kind of configuration file entry (myKey). I can store config entry in app.config but if I want to change it from on->off or otherwise it would require to restart Windows Service, and I want to avoid it. I want my application to run and pick up changes in configuration.

The question is: is there a build in mechanism in .NET that addresses that problem ? I guess I could create my own config file, then use FileSystemWatcher etc… But perhaps .NET allows to use external config files and will reload value ??

ConfigurationManager.AppSettings["myKey"]

Thanks, Pawel

EDIT 1: Thanks for replies. However I wrote following snippet and it doesn’t work (I tried creating appSettingSection in both places: before and inside loop):

static void Main(string[] args)
{
    Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
    // AppSettingsSection appSettingSection = (AppSettingsSection)config.GetSection("appSettings");
    for (int i = 0; i < 10; i++)
    {
        ConfigurationManager.RefreshSection("appSettings");
        AppSettingsSection appSettingSection = (AppSettingsSection)config.GetSection("appSettings");
        string myConfigData = appSettingSection.Settings["myConfigData"].Value; // still the same value, doesn't get updated
        Console.WriteLine();
        Console.WriteLine("Using GetSection(string).");
        Console.WriteLine("AppSettings section:");
        Console.WriteLine(
          appSettingSection.SectionInformation.GetRawXml()); // also XML is still the same
        Console.ReadLine();
    }
}

I manually edit config file when application stops on Console.ReadLine().

  • 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-21T13:57:35+00:00Added an answer on May 21, 2026 at 1:57 pm

    Once the original app.config file is loaded, it’s values are cached so as you know, you’ll have to restart the app. The way around this is to create a new config object and read the keys manually like this:

    var appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
    string myConfigData = appConfig.AppSettings.Settings["myConfigData"].Value;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following issue and I would like to know what exactly happens.
I'm trying to adress the following issue: I have a server side .net application
I have the following application which replicates an issue I'm having in a larger
I have the following issue: when a stored proc is called from my application,
I have the following issue. I have deployed a smart client application to several
I have the following issue: I have a MVC application, in some action of
I am running into the following issue: Our members have a desire for personalized
I have the following issue, Im creating a windows 7 gadget, which uses Iframe
I am struggling with the following issue: I have an XML string that contains
I have the following issue and I would really appreciate your help: I have

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.