473,569 Members | 2,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4882
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.

"Scanner200 1" <je************ @hotmail.com> wrote in message
news:#3******** ******@TK2MSFTN GP12.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.r illing.net> wrote in message
news:##******** ******@TK2MSFTN GP15.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.

"Scanner200 1" <je************ @hotmail.com> wrote in message
news:#3******** ******@TK2MSFTN GP12.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
256
by: Scanner2001 | last post by:
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...
2
2216
by: Pieter | last post by:
Hi, I'm using the Settings.settings of VB.NET to define a Connectionstring (Scope = application). When I deploy the Solution, and change this Setting in the app.config-file, it seems that itdoesn't affect the Application at all! It still uses the old value. Are the Settings.Setting hardcoded somewhere in the application? I can't find...
2
11980
by: Keith Elder | last post by:
Let's say you have a stand alone C# library project that is your datalayer. When this library compiles it will produce "My.DataLayer.dll" for example. In the project you use all the new whizbang DataSet generation tools to create some datasets, etc in your DataLayer project. When you setup a connection string it adds a settings.settings...
2
1333
by: VB Programmer | last post by:
I used to be able to change minor settings in my web.config file when it was on the web server, such as <appSettings> elements. In ASP.NET 2.0 I noticed that there is a web.config AND a PrecompiledApp.config file. So, how can I change <appSettings> (or other) elements once it's been deployed to the server? Thanks!
5
5723
by: Keith | last post by:
Hello all, I have a C# Windows Forms app. It is in namespace App.GUI. It builds to Nav.exe. I have entered an application level setting using the designer. Its type is string, name is "FOO" and value is "monkey". I've tried the following ways to retrieve the value and only one works: //Returns null Configuration config =...
8
1897
by: aabdis | last post by:
Hello All.... I have a question... i have two Windows apps (one UI, and one service) which use a common DLL that hands out database results and such to the two apps. The DLL always connects to the DB the same way, regardless of which app calls it. So i wanted to store info in the config file for the DLL... only to find out it wont read that...
1
6048
by: Sankalp | last post by:
Hi, I am using VB 2005. My application has many data bound controls. The connection is stored in the app.config file. I want the application to start with a default connection string and while during the runtime, the user can click on a button and change the connection string without exiting the application. I would really appreciate...
7
2506
by: harry | last post by:
I've set my database connection as an Application.Setting using the designer. Since Application.Settings are read only, how do I change the connection properties when deploying to another machine ? Thanks Harry
4
25982
by: olduncleamos | last post by:
I am trying to share one config file between multiple console apps. Is there anyway I can set the config file name for the current application? Thanks in advance.
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.