473,797 Members | 3,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.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
Aug 31 '07 #1
2 3628
On Aug 31, 10:21 am, Jan Eliasen <elia...@nospam .nospamwrote:

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

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

Properties.Sett ings.Default.De bugLogging

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.co mwrote:
>You're asking for the *default value*. Just use

Properties.Set tings.Default.D ebugLogging

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
1678
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 build properties page and allow it there. For some reason, my project does not have a build properties page, only a configuration properties page. Can I add a build properties page somehow? Is this because I am not using the command line...
7
2605
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 propertieName2=propertieValue2 propertieName3=propertieValue3
1
1874
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 together. The idea is to access the properties this way configuration.Database.Server.IPAddress instead of configuration.Database_Server_IPAddress
0
2853
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 add/edit any values for a setting with type NameValueCollection. Nor can I get a NameValueCollection to persist to the User Settings via code using a simple C# Console App... Is this a user error or ?
0
1251
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" encoding="utf-8" ?> <configuration> <configSections> <section name="Employees" type="CustomConfigurationTest.MyConfigSection, CustomConfigurationTest" /> </configSections>
13
7147
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 noticed that the designer creates and app.config that gets copied to the output directory as a .exe.config or .dll.config. In this setup any Application Scope property that is in the .exe.config file can be read in from the file and used. My...
1
22021
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 PROPS, "< input.properties" or die "unable to open configuration file"; my $properties = new Config::Properties();
7
2209
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
4749
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 q37_prf_code, dbo.co_individual.ind_first_name AS q37_first_name, dbo.co_individual.ind_last_name AS q37_last_name, dbo.co_individual.ind_mid_name AS q37_ind_mid_name, dbo.co_individual.ind_sfx_code AS...
0
9685
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9536
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10245
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10021
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9063
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7559
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4131
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.