J
Jan Eliasen
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.settings
file, and an app.config file that reflects the values in the
Settings.settings file. If I add properties to the Settings.settings
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.Settings.Default.Properties[DEBUGLOGGINGCONFIGKEY].DefaultValue.ToString();
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:
ConfigurationManager.AppSettings[DEBUGLOGGINGCONFIGKEY]
then I just get null back.
In the old days (and in the .NET 2.0 days) I always use the
appSettings element under "configuration" 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" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="thydata.dk.apm.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<thydata.dk.apm.Properties.Settings>
<setting name="QueuePath" serializeAs="String">
<value>.\ax_to_tbs</value>
</setting>
<setting name="thydata_dk_apm_TBS_TMHost"
serializeAs="String">
<value>http://localhost/TMHost Web Service/TMHost.asmx</value>
</setting>
<setting name="DebugLogging" serializeAs="String">
<value>True</value>
</setting>
</thydata.dk.apm.Properties.Settings>
</applicationSettings>
</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: (e-mail address removed)
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.settings
file, and an app.config file that reflects the values in the
Settings.settings file. If I add properties to the Settings.settings
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.Settings.Default.Properties[DEBUGLOGGINGCONFIGKEY].DefaultValue.ToString();
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:
ConfigurationManager.AppSettings[DEBUGLOGGINGCONFIGKEY]
then I just get null back.
In the old days (and in the .NET 2.0 days) I always use the
appSettings element under "configuration" 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" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="thydata.dk.apm.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<thydata.dk.apm.Properties.Settings>
<setting name="QueuePath" serializeAs="String">
<value>.\ax_to_tbs</value>
</setting>
<setting name="thydata_dk_apm_TBS_TMHost"
serializeAs="String">
<value>http://localhost/TMHost Web Service/TMHost.asmx</value>
</setting>
<setting name="DebugLogging" serializeAs="String">
<value>True</value>
</setting>
</thydata.dk.apm.Properties.Settings>
</applicationSettings>
</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: (e-mail address removed)