473,394 Members | 1,748 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.

Properties and configuration

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.ApplicationSettingsGrou p, 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%20Web%20Service/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: ja*@eliasen.dk
Aug 31 '07 #1
2 3597
On Aug 31, 10:21 am, Jan Eliasen <elia...@nospam.nospamwrote:

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

You're asking for the *default value*. Just use

Properties.Settings.Default.DebugLogging

The "default" part here just means "use the settings which are
*loaded* by default" which isn't the same as the default values of
those settings :)

Jon

Aug 31 '07 #2
On Fri, 31 Aug 2007 05:49:04 -0700, "Jon Skeet [C# MVP]"
<sk***@pobox.comwrote:
>You're asking for the *default value*. Just use

Properties.Settings.Default.DebugLogging

The "default" part here just means "use the settings which are
*loaded* by default" which isn't the same as the default values of
those settings :)
I just KNEW there had to be something I just didn't get... I have
spend the better part of 2 days searching for examples that matched my
setup, but couldn't find it...

Thanks, Jon!

--
eliasen, representing himself and not the company he works for.

Private blog: http://blog.eliasen.dk

Private email: ja*@eliasen.dk
Sep 2 '07 #3

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

Similar topics

1
by: lester | last post by:
I'm using a C++ dll and need to allow unsafe code because the dll function takes char *. I am using Visual Studio.NET 2002. Everything I've seen says to go to the project properties page, then the...
7
by: ffmelo | last post by:
I need something like java.util.Properties class... I want to store properties in a text file and to get at runtime. Example in java: text file ------ propertieName1=propertieValue1...
1
by: Corrado Labinaz | last post by:
Hi everyone, I've a Configuration class with almost 200 read only properties. This class makes available configuration data to my whole application. I would like to group realted properties...
0
by: =?Utf-8?B?UmljayBHbG9z?= | last post by:
For some unknown reason (user error?), I cannot get a NameValueCollection to persist in the app.config file. Unlike other settings, I cannot get the String Collection Editor GUI to allow my to...
0
by: style | last post by:
In the following sample I declared a custom configuration section within my app.config. As you can see, the lastName attribute of the second employee element is missing: <?xml version="1.0"...
13
by: Dave | last post by:
When using the properties designer to store application wide properties how do you get this to work across a project group containing an EXE and a collection of DLLs. I'm using C#.Net 2005. I...
1
by: bhavanirayala | last post by:
Hi, I am new to perl.Basically I am from java.Now I am getting error while i reading the configuration parameters in perl. #!/usr/bin/perl use Config::Properties; # reading... open...
7
by: jkaashoek | last post by:
What is the best mechanism for using custom application properties? Do these go into the php.ini file or somewhere else? And what functions are available to handle such properties?
2
OraMaster
by: OraMaster | last post by:
Hi All, Below is the SQL of one view in my DB. SELECT cxc.cst_key AS q37_individual_key, dbo.co_individual.ind_cst_key AS q37_related_ind_key, dbo.co_individual.ind_prf_code AS...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.