471,338 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

Change app.config settings

I have a service with settings in the app.config file. I would like to
be able to change these settings without restarting the service. Something
similar to a web.config with web services. Whenever I change a setting, for
example the folder that data is written to, the change does not seem to
register. What I believe is that the app.config is read in at the startup of
the exe (windows service), and then never read again. Is there a way to
force it to read it again? I would prefer not to create another config file
if I do not have to.
Also, is there a more specific group to post to? Such as windows
services newsgroup?

Thanks,
J

Jul 21 '05 #1
2 4730
Everything is possible, but not always easy. The configuration file is
handled by .NET and therefore you, directly, cannot force it to reload. One
thing you might do is to alter your architecture such that you are able to
load a new AppDomain instance. Then you can pass the config file which is
loaded, of coarse, this will essentially create a copy of your program in
memory. This is sort of what ASP.NET does. When the config has changed, a
separate processing space is loaded to handle future requests (I think this
is how it works). You could also do away with the whole .NET configuration
system and write your own that can be loaded anytime you want.

Given all this, it just might be easier to restart the service.

"Scanner2001" <je************@hotmail.com> wrote in message
news:#3**************@TK2MSFTNGP12.phx.gbl...
I have a service with settings in the app.config file. I would like to
be able to change these settings without restarting the service. Something
similar to a web.config with web services. Whenever I change a setting, for example the folder that data is written to, the change does not seem to
register. What I believe is that the app.config is read in at the startup of the exe (windows service), and then never read again. Is there a way to
force it to read it again? I would prefer not to create another config file if I do not have to.
Also, is there a more specific group to post to? Such as windows
services newsgroup?

Thanks,
J

Jul 21 '05 #2
I would just write a simple class and use XmlSerializer to load and save
config.

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:##**************@TK2MSFTNGP15.phx.gbl...
Everything is possible, but not always easy. The configuration file is
handled by .NET and therefore you, directly, cannot force it to reload. One thing you might do is to alter your architecture such that you are able to
load a new AppDomain instance. Then you can pass the config file which is
loaded, of coarse, this will essentially create a copy of your program in
memory. This is sort of what ASP.NET does. When the config has changed, a separate processing space is loaded to handle future requests (I think this is how it works). You could also do away with the whole .NET configuration system and write your own that can be loaded anytime you want.

Given all this, it just might be easier to restart the service.

"Scanner2001" <je************@hotmail.com> wrote in message
news:#3**************@TK2MSFTNGP12.phx.gbl...
I have a service with settings in the app.config file. I would like to be able to change these settings without restarting the service. Something similar to a web.config with web services. Whenever I change a setting, for
example the folder that data is written to, the change does not seem to
register. What I believe is that the app.config is read in at the

startup of
the exe (windows service), and then never read again. Is there a way to
force it to read it again? I would prefer not to create another config

file
if I do not have to.
Also, is there a more specific group to post to? Such as windows
services newsgroup?

Thanks,
J



Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Scanner2001 | last post: by
2 posts views Thread by Keith Elder | last post: by
2 posts views Thread by VB Programmer | last post: by
8 posts views Thread by aabdis | last post: by
4 posts views Thread by olduncleamos | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.