PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Change app.config settings

 
 
Scanner2001
Guest
Posts: n/a
 
      18th Feb 2005
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



 
Reply With Quote
 
 
 
 
Peter Rilling
Guest
Posts: n/a
 
      18th Feb 2005
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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
William Stacey [MVP]
Guest
Posts: n/a
 
      19th Feb 2005
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" <(E-Mail Removed)> wrote in message
news:##(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> > 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
> >
> >
> >

>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dll config and web.config and Label Expressions (binding label text to dll config settings) CSharpner Microsoft ASP .NET 0 9th Apr 2007 10:00 PM
App.Config change doesn't affect My.Settings? Pieter Microsoft Dot NET Framework 2 8th Dec 2005 03:14 PM
App.Config change doesn't affect My.Settings? Pieter Microsoft Dot NET 2 8th Dec 2005 03:14 PM
App.Config change doesn't affect My.Settings? Pieter Microsoft VB .NET 2 8th Dec 2005 03:14 PM
Custom Installation Project? Ask For Sql settings and execute script. and change web.config? Luis Esteban Valencia Muņoz Microsoft ASP .NET 0 23rd May 2005 10:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:08 AM.