Solved

Configuration App settings in memory

Posted on 2015-01-26
3
83 Views
Last Modified: 2015-01-27
I have an application where the configuration values are read from various classes some of which are static.

How can I ensure that when I get the values from the appSettings the application does not need to reopen the app.config file but uses these from memory.

I had thought of creating a class that I can pass around that just loads the settings into say a List<String>.

Is there a standard way of holding the appSettings in memory and so ensuring better performance?
0
Comment
Question by:jetbet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 34

Expert Comment

by:it_saige
ID: 40571526
The ConfigurationManager class does load the application settings in memory.

This is why Application Settings that are changed while a program is running do not take affect until the application is restarted (or you explicitly call the RefreshSection method).

You can refer to this blog post for more information: http://www.c-sharpcorner.com/UploadFile/akkiraju/refreshing-the-net-application-to-read-modified-configurati/

-saige-
0
 
LVL 40
ID: 40571851
I have to partially contradict it_saige.

Yes, the application settings are loaded into memory. In fact, it takes the role of the class that you want to create, so I do not see the need for it. Change a setting, and it is changed for the life of the current run of the application.

However, the settings do take effect in the current run of the application as soon as you change them. Change a setting, read it back, it it has the new value.

It's their persistence between runs of the application that could be in question if you do not Save them back to app.config before exiting the application.
0
 
LVL 34

Accepted Solution

by:
it_saige earned 500 total points
ID: 40572835
Let me qualify my statement for clarity.  Changing the AppSetting by editing the XML file directly, does not affect the setting while the application is running (this is what the blog post above illustrates).

However, James is correct, if you change the setting that is loaded into memory, then the setting change takes affect immediately.  Also, as James points out, you do need to save the setting(s) back to the XML file when you change them.

-saige-
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question