473,394 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Watching changes in the App.config file on runtime

Hi,

I am creating a web service, which needs to take some actions based on the
config file. I need a way to listen the changes as they occur in the config
file so that the service can take appropriate action for the cahnges. Is
there any way i can implement this.

Thanks,
Ajay
Nov 16 '05 #1
6 5921
Check out the FileSystemWatcher class in the framework:

http://msdn.microsoft.com/library/de...sctortopic.asp
This will provide everything you need.

"Ajay Pal Singh" <aj***@nagarro.com> wrote in message
news:ul*************@TK2MSFTNGP15.phx.gbl...
Hi,

I am creating a web service, which needs to take some actions based on the
config file. I need a way to listen the changes as they occur in the
config
file so that the service can take appropriate action for the cahnges. Is
there any way i can implement this.

Thanks,
Ajay

Nov 16 '05 #2
Hi,

You can use a FileSystemWatcher to monitor the file

What I do not know for sure is the consecuence of changing this file, in a
web app if you change it the application is restarted, you lose all the
sessions and you don't need to check for changes. I don't know what happen
in a web service.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ajay Pal Singh" <aj***@nagarro.com> wrote in message
news:ul*************@TK2MSFTNGP15.phx.gbl...
Hi,

I am creating a web service, which needs to take some actions based on the
config file. I need a way to listen the changes as they occur in the
config
file so that the service can take appropriate action for the cahnges. Is
there any way i can implement this.

Thanks,
Ajay

Nov 16 '05 #3
Thanks for the response.
But the problem I am facing is little different:

I want to use the System.Configuration.ConfigurationSetting.AppSetti ngs
member function to retrieve settings from the my app.config file.
If some of the settings in the app.config are changed and when I read back
values from
System.Configuration.ConfigurationSetting.AppSetti ngs member function it is
the original one, is there a way to force reading back the .config file ?
"PJ Olson" <pe*****@sux.com> wrote in message
news:OG**************@TK2MSFTNGP14.phx.gbl...
Check out the FileSystemWatcher class in the framework:

http://msdn.microsoft.com/library/de...sctortopic.asp

This will provide everything you need.

"Ajay Pal Singh" <aj***@nagarro.com> wrote in message
news:ul*************@TK2MSFTNGP15.phx.gbl...
Hi,

I am creating a web service, which needs to take some actions based on the config file. I need a way to listen the changes as they occur in the
config
file so that the service can take appropriate action for the cahnges. Is
there any way i can implement this.

Thanks,
Ajay


Nov 16 '05 #4
Thanks for the response.
But the problem I am facing is following:

I want to use the System.Configuration.ConfigurationSetting.AppSetti ngs
member function to retrieve settings from the my app.config file.
If some of the settings in the app.config are changed and when I read back
values from
System.Configuration.ConfigurationSetting.AppSetti ngs member function it is
the original one, is there a way to force reading back the .config file ?

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:eA**************@TK2MSFTNGP09.phx.gbl...
Hi,

You can use a FileSystemWatcher to monitor the file

What I do not know for sure is the consecuence of changing this file, in a
web app if you change it the application is restarted, you lose all the
sessions and you don't need to check for changes. I don't know what happen
in a web service.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ajay Pal Singh" <aj***@nagarro.com> wrote in message
news:ul*************@TK2MSFTNGP15.phx.gbl...
Hi,

I am creating a web service, which needs to take some actions based on the config file. I need a way to listen the changes as they occur in the
config
file so that the service can take appropriate action for the cahnges. Is
there any way i can implement this.

Thanks,
Ajay


Nov 16 '05 #5
>I want to use the System.Configuration.ConfigurationSetting.AppSetti ngs
member function to retrieve settings from the my app.config file.
If some of the settings in the app.config are changed and when I read back
values from
System.Configuration.ConfigurationSetting.AppSett ings member function it is
the original one, is there a way to force reading back the .config file ?


No - you will have to "roll your own" and read and interpret the
app.config file (a XML file) yourself.

The basic .NET framework does *NOT* assume that those files are
changed while the app is running, and thus they read the settings
ONCE, at startup, and never again after that (they're being cached).

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Nov 16 '05 #6
Store the settings in a custom application specific Settings class. Use that
class to receive updates and update the web.config at the same time as well
as providing the current settings to your web service.

Provide a property for each setting will also provide the equivalent of a
Typed Dataset type environment preventing runtime errors due to mispelled
app settings.

"Pretend" the web service has no knowledge of the
System.Configuration.ConfigurationSetting.AppSetti ngs area and uses your
custom Settings class instead.

Your app will then always have the latest values at hand!

"Ajay Pal Singh" <aj***@nagarro.com> wrote in message
news:Oq**************@TK2MSFTNGP09.phx.gbl...
Thanks for the response.
But the problem I am facing is little different:

I want to use the System.Configuration.ConfigurationSetting.AppSetti ngs
member function to retrieve settings from the my app.config file.
If some of the settings in the app.config are changed and when I read back
values from
System.Configuration.ConfigurationSetting.AppSetti ngs member function it
is
the original one, is there a way to force reading back the .config file ?
"PJ Olson" <pe*****@sux.com> wrote in message
news:OG**************@TK2MSFTNGP14.phx.gbl...
Check out the FileSystemWatcher class in the framework:

http://msdn.microsoft.com/library/de...sctortopic.asp


This will provide everything you need.

"Ajay Pal Singh" <aj***@nagarro.com> wrote in message
news:ul*************@TK2MSFTNGP15.phx.gbl...
> Hi,
>
> I am creating a web service, which needs to take some actions based on the > config file. I need a way to listen the changes as they occur in the
> config
> file so that the service can take appropriate action for the cahnges.
> Is
> there any way i can implement this.
>
> Thanks,
> Ajay
>
>



Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Danny | last post by:
Hello, I was wondering if anyone knew if it was possible to make changes to an application's App.config file at runtime and then be able to access those changes immediately. The following is...
9
by: Tim D | last post by:
Hi, I originally posted this as a reply to a rather old thread in dotnet.framework.general and didn't get any response. I thought it might be more relevant here; anyone got any ideas? My...
8
by: Subra Mallampalli | last post by:
Hi, I am trying to use <runtime> section within the web.config file. However, the contents of the <runtime> section seem to be ignored. What am i missing here? Is <runtime> section not used by...
3
by: Lisa | last post by:
Suddenly, the encoding in my exe.config file changes from UTF-8 to Windows-1252 every time I try to debug my winform app. This causes the old application configuration error when I try to debug...
4
by: keithb | last post by:
How can an application change settings in the web.config file? I need to allow users to configure SMTP email settings with functionality similar to that provided developers by the ASP.NET Web Site...
0
by: Dave A | last post by:
When I register a remoting service programmatically things work great but when I register the service using a config file I get the error "Requested Service not found" when invoking a server...
0
by: Matt Adamson | last post by:
Guys, When writing unit tests for our assemblies we'd like to change configuration values at runtime for some tests i.e. to test all code paths are executed. e.g. one method would create a test...
1
by: Harold Howe | last post by:
When .NET loads an app.config at runtime (myapp.exe.config), will it honor an entity declaration? Based on what I am seeing, the answer is no, but I think, or hope, that I am doing something wrong....
3
by: Eric | last post by:
I'm trying to manipulae my app.config file. Below is code to test that I can remove a ConfigurationSection. It looks like its working, but the app.config file is not changed when I look at it...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.