efficient use of a configuration file

J

Josh Carlisle

I have a server activated .Net remoting component so it's life time is very
short. During a method call I access a configuration file (normal XML
document) to decide whether to execute a set of logic (specifically some
custom logging/auditing routines). I'm concerned with the overhead of
opening a XML document for each call to obtain these settings regardless of
whether the logging is done or not (based on settings in the config file).
I'm stuck using a configuration file but I'm curious if there is any
advice/best practices for optimally access the config file with as little
overhead as possible and additionally the most efficient way of reading the
XML data file (e.g. xmlserialized class, dataset, raw XML read, etc). I do
plan on getting some times on different methods but I thought I'd get some
advice first.

Thanks in advance.

Josh
 
J

Jay B. Harlow [MVP - Outlook]

Josh,
Are you using your own XML file or are you using the app.config file via the
System.Configuration namespace?

If you are using the System.Configuration.ConfigurationSettings name the
runtime will cache the app.config file in memory, as long as the remoting
component is active the settings are cached in memory & will not be re-read
from disk.

If you are using your own XML file, you could probably store the settings in
a shared variable (on the server) and only read them in the class
constructor (shared sub new).

Shared Variables are similar to using a Module, however shared variables
IMHO are "better" encapsulated as you are required to qualify them with a
class name.

Hope this helps
Jay
 
J

Josh Carlisle

Jay,

Thx for the quick response. I'm using my own XML file for the configuration.
I hadn't thought of the shared variable options. I've used shared functions
for utilities functions in the past but I had never thought of the shared
variable. That would be an excellent option. Thanks for much for the
suggestion!

Josh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top