473,785 Members | 2,298 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 2650
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
9645
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
9481
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
10341
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
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...
1
10095
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9954
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
8979
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...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.