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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:59:55+00:00 2026-05-29T07:59:55+00:00

When are settings from app.config actually read by application? Suppose I have a windows

  • 0

When are settings from app.config actually read by application?

Suppose I have a windows service and some app settings for it. In code I have a method where some setting is used. Method is being called in every iteration, not just once during all the time. If I change the setting value through the configuration file should I restart the service for it to be “refreshed” inside or will it be accepted the next time without any interaction from my side?

  • 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-29T07:59:57+00:00Added an answer on May 29, 2026 at 7:59 am

    You need to call ConfigurationManager.RefreshSection method to get the latest values read directly from disk. Here’s a simple way to test and provide answer to your question:

    static void Main(string[] args)
    {
        while (true)
        {
            // There is no need to restart you application to get latest values.
            // Calling this method forces the reading of the setting directly from the config.
            ConfigurationManager.RefreshSection("appSettings");
            Console.WriteLine(ConfigurationManager.AppSettings["myKey"]);
    
            // Or if you're using the Settings class.
            Properties.Settings.Default.Reload();
            Console.WriteLine(Properties.Settings.Default.MyTestSetting);
    
            // Sleep to have time to change the setting and verify.
            Thread.Sleep(10000);
        }
    }
    

    My app.config containing:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <configSections>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
          <section name="ConsoleApplication2.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
      </configSections>
      <appSettings>
        <add key="myKey" value="Original Value"/>
      </appSettings>
      <userSettings>
        <ConsoleApplication2.Properties.Settings>
          <setting name="MyTestSetting" serializeAs="String">
            <value>Original Value</value>
          </setting>
        </ConsoleApplication2.Properties.Settings>
      </userSettings>
    </configuration>
    

    After you start the application, open the app.config within the build folder, and change the value of the appSetting “myKey”. You’ll see the new value printed out to the console.

    To answer the question, yes they are cached on the first time they are each read I think, and to force the read straight from the disk, you need to refresh the section.

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

Sidebar

Related Questions

I have a windows service that reads from app.config. I want some settings to
I have a command line application that reads some settings from the app.config file,
I need to read a setting from the appsettings section (defined in app.config) in
I'm using Castle DictionaryAdapter in order to get the application settings from the app.config
How to load application settings to NHibernate.Cfg.Configuration object by using System.Configuration.ConfigurationManager from App.config?
I am writing code that read customized config section from app.config, but I get
I am trying to read some settings from php.ini using zend. The API that
I'm trying to fetch some settings from my membership provider in my asp.net application
How should I create application wide utility/manager classes that read settings from the database?
If i am reading one of my application settings from the web.config everytime when

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.