?
Solved

Configuration App settings in memory

Posted on 2015-01-26
3
Medium Priority
?
92 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 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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 …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

741 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