473,770 Members | 4,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ConfigurationSe ttings.AppSetti ngs["foo"]

Could someone provide me with details or a link on how the line of code
executes underneath the hood? Assume it's executed in an ASP.NET
application.

string blah = ConfigurationSe ttings.AppSetti ngs["foo"]

Once your application has called for the "foo" key once, how expensive is to
call the same line again? My gut tells me that the CLR likely stores these
values in memory in a string dictionary or similar. Looking up the value
requires the potentially sorted collection to "lookup" the key again and
retrieve the value hopefully leveraging a b-tree or similar in the sorted
collection.

Perhaps it works a different way? Just curious. Thanks.

Mark
Jan 11 '07 #1
8 2649
Hi,

"Mark" <ma*********@no spam.nospamwrot e in message
news:e6******** ******@TK2MSFTN GP03.phx.gbl...
| Could someone provide me with details or a link on how the line of code
| executes underneath the hood? Assume it's executed in an ASP.NET
| application.
|
| string blah = ConfigurationSe ttings.AppSetti ngs["foo"]
|
| Once your application has called for the "foo" key once, how expensive is
to
| call the same line again?

Not much, only a lookup in some struct in memory ( hashtable, etc). At some
moment the file needs to be loaded. IMO (but I have no fact to prove it) it
happens when the application loads.

Also remember that even as the file remains closed the engine keeps an eye
on it (probably using a FileSystemWatch er) to detect change, if it does it
reload the entire app

--
Ignacio Machin
machin AT laceupsolutions com
Jan 11 '07 #2

It loads the first time ConfigurationSe ttings.AppSetti ngs is called,
not necessarily on application load.

Hard to test in an ASP.NET app but in a winform/console app it's easy
to verify because you can change the app.config file before calling
ConfigurationSe ttings.AppSetti ngs and your changes are reflect (not
usually a good idea but we did this in one situation where we wanted a
console app to share a config file with another app sothe console app
copied the file on startup).

Sam
------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On Thu, 11 Jan 2007 15:16:47 -0500, "Ignacio Machin \( .NET/ C# MVP
\)" <machin TA laceupsolutions .comwrote:
>| string blah = ConfigurationSe ttings.AppSetti ngs["foo"]
|
Not much, only a lookup in some struct in memory ( hashtable, etc). At some
moment the file needs to be loaded. IMO (but I have no fact to prove it) it
happens when the application loads.

Also remember that even as the file remains closed the engine keeps an eye
on it (probably using a FileSystemWatch er) to detect change, if it does it
reload the entire app
Jan 11 '07 #3
if ur accessing web.config, use WebConfiguratio nManager - its faster than the
basic ConfigurationMa nager.
Jan 12 '07 #4

WebConfiguratio nManager is new to .NET 2.0 and the original post asked
about ConfigurationSe ttings.AppSetti ngs which is obsolete in .NET 2.0,
implying he's using .NET 1.1.

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On Thu, 11 Jan 2007 17:31:00 -0800, XOR
<XO*@discussion s.microsoft.com wrote:
>if ur accessing web.config, use WebConfiguratio nManager - its faster than the
basic ConfigurationMa nager.
Jan 12 '07 #5
Hi,

"Samuel R. Neff" <sa********@nom ail.comwrote in message
news:hb******** *************** *********@4ax.c om...
|
| It loads the first time ConfigurationSe ttings.AppSetti ngs is called,
| not necessarily on application load.
|
| Hard to test in an ASP.NET app but in a winform/console app it's easy
| to verify because you can change the app.config file before calling
| ConfigurationSe ttings.AppSetti ngs and your changes are reflect (not
| usually a good idea but we did this in one situation where we wanted a
| console app to share a config file with another app sothe console app
| copied the file on startup).

I think that the treatmean is different between web and win apps, in win app
as you mentioned before you can change the config while the app is running
and before the app access it without any consequence. If you do so in a web
app the application will restart.
--
Ignacio Machin
machin AT laceupsolutions com
Jan 12 '07 #6

The treament related to changing the file is different, but the O.P.'s
question was about when the data is loaded and how it's cached which
is the same--on first access.

Sam
------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Fri, 12 Jan 2007 09:58:43 -0500, "Ignacio Machin \( .NET/ C# MVP
\)" <machin TA laceupsolutions .comwrote:
>Hi,

"Samuel R. Neff" <sa********@nom ail.comwrote in message
news:hb******* *************** **********@4ax. com...
|
| It loads the first time ConfigurationSe ttings.AppSetti ngs is called,
| not necessarily on application load.
|
| Hard to test in an ASP.NET app but in a winform/console app it's easy
| to verify because you can change the app.config file before calling
| ConfigurationSe ttings.AppSetti ngs and your changes are reflect (not
| usually a good idea but we did this in one situation where we wanted a
| console app to share a config file with another app sothe console app
| copied the file on startup).

I think that the treatmean is different between web and win apps, in win app
as you mentioned before you can change the config while the app is running
and before the app access it without any consequence. If you do so in a web
app the application will restart.
Jan 16 '07 #7
Hi,

"Samuel R. Neff" <sa********@nom ail.comwrote in message
news:dk******** *************** *********@4ax.c om...
|
| The treament related to changing the file is different, but the O.P.'s
| question was about when the data is loaded and how it's cached which
| is the same--on first access.

Do you have a link where this is described?

Honestly I would find dificult to understand why it's loaded at first use,
and being "watched" from the beginning. Unless of course that the first
thing that happen when an app is loaded depends of the config, then it will
load (at the start of the app). In this escenario the file is loaded at
first use which coincide with the load of the app. IMHO I think this is the
way it happens

--
Ignacio Machin
machin AT laceupsolutions com
Jan 16 '07 #8

Use Reflector and look at ConfigurationSe ttings.GetConfi g. It's
initialized on first use.

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On Tue, 16 Jan 2007 13:50:07 -0500, "Ignacio Machin \( .NET/ C# MVP
\)" <machin TA laceupsolutions .comwrote:
>Hi,

"Samuel R. Neff" <sa********@nom ail.comwrote in message
news:dk******* *************** **********@4ax. com...
|
| The treament related to changing the file is different, but the O.P.'s
| question was about when the data is loaded and how it's cached which
| is the same--on first access.

Do you have a link where this is described?

Honestly I would find dificult to understand why it's loaded at first use,
and being "watched" from the beginning. Unless of course that the first
thing that happen when an app is loaded depends of the config, then it will
load (at the start of the app). In this escenario the file is loaded at
first use which coincide with the load of the app. IMHO I think this is the
way it happens
Jan 16 '07 #9

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

Similar topics

3
6186
by: Dave | last post by:
I am a user of the ConfigurationSettings.AppSettings("KeyName") in asp.net 1.1 so after reading about the new ConnectionStrings collection in "Intoducing Microsoft ASP.NET 2.0 by Dino Esposito on page 137 I excitedly started a demo project to try it out. I am getting an error in the editor. It's telling me that ConnectionStrings is not a member of System.Configuration.ConfigurationSettings. What am I doing wrong? Dave
0
9595
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
10059
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
9873
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
8891
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
7420
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...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
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
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
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.