Using app.exe.config

Q

Q

Hello you all,

I am using the app.exe.config file to store some settings of my application.
E.g. I'm storing the name of the SMTP-Server the application has to use
to send it's error messages to a specific user.
The problem is that, when I change this setting from within the application,
I have to
restart the application for the new settings to have effect.

Is there a way to change to the new settings immediately, without restarting
the application?

Regards,

Q
 
H

Herfried K. Wagner [MVP]

Q said:
I am using the app.exe.config file to store some settings of my
application.
E.g. I'm storing the name of the SMTP-Server the application has to use
to send it's error messages to a specific user.
The problem is that, when I change this setting from within the
application,
I have to
restart the application for the new settings to have effect.

Simply don't use config files to store user preferences:

Storing and loading user preferences
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=userpreferences&lang=en>
 
N

Nick Malik [Microsoft]

I don't remember the ConfigurationSettings object doing any caching... are
you reading from the config file once in your code, and then looking at
internal variables after that? If so, it's hard to blame .Net for this.

Maybe if your code would always pull that particular value from the config
file instead of from a private member variable, or if you would reread the
config file if it has been more than five minutes since you last read it, or
perhaps, you store the date of the original file locally and check the date
each time to see if it has changed...

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 

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