Hi
I am having some problems reading configuration values from a
configuration file, using C# 2.0.
I have programmed a Windows Service, and this part goes well - it runs
nicely.
Now, the Windows Service must call a Web Service every now and then. I
have added the web reference, and made it dynamic, so I can change the
URL later in the configuration file. This creates a Settings.settin gs
file, and an app.config file that reflects the values in the
Settings.settin gs file. If I add properties to the Settings.settin gs
file, they are also created for me in app.config and the other way
around. Great.
But if I read the properties in my code like this:
Properties.Sett ings.Default.Pr operties[DEBUGLOGGINGCON FIGKEY].DefaultValue.T oString();
then changes I make to app.config after deployment of the web service
don't work. The old values that were present at compile time are
always used.
If I try this:
ConfigurationMa nager.AppSettin gs[DEBUGLOGGINGCON FIGKEY]
then I just get null back.
In the old days (and in the .NET 2.0 days) I always use the
appSettings element under "configurat ion" to store applications
settings. But this time, because I made the web service dynamic,
something else has been created for me, and I can not seem to handle
it.
My app.config file looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<configSections >
<sectionGroup name="applicati onSettings"
type="System.Co nfiguration.App licationSetting sGroup, System,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9" >
<section name="thydata.d k.apm.Propertie s.Settings"
type="System.Co nfiguration.Cli entSettingsSect ion, System,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
requirePermissi on="false" />
</sectionGroup>
</configSections>
<applicationSet tings>
<thydata.dk.apm .Properties.Set tings>
<setting name="QueuePath " serializeAs="St ring">
<value>.\ax_to_ tbs</value>
</setting>
<setting name="thydata_d k_apm_TBS_TMHos t"
serializeAs="St ring">
<value>http://localhost/TMHost%20Web%20 Service/TMHost.asmx</value>
</setting>
<setting name="DebugLogg ing" serializeAs="St ring">
<value>True</value>
</setting>
</thydata.dk.apm. Properties.Sett ings>
</applicationSett ings>
</configuration>
Can anyone tell me how I will get to the DebugLogging value at runtime
in my code?
Thanks!
--
eliasen, representing himself and not the company he works for.
Private blog: http://blog.eliasen.dk
Private email: ja*@eliasen.dk