connectionStrings and appSettings have a predefined place in config file

T

Tony Johansson

Hi!

I'm reading a section in a book from Microsoft Press called .NET FRAMEWORK
2.0 Application Development Foundation.
about Installing and Configuring Application.

In the book that I'm reading it says that I hope somebody might explain.
"Other common settings are configuration values that are already defined for
you by the .NET Framework. Thet comprise two primary sections,
connectionStrings and appSettings. In many ways, these configuration values
are used identically to any other configuration component; however they do
contain some nuance that give them distinct advantages over other items.
Because they are treated differently than other settings, they have a
predefined location in the configuration file where they need to be placed."

I just wonder this part of the text above *predefined location in the
configuration file where they need to be placed*
What does that mean ?
I mean a predefined place where is that ? In the beginning at the end or
what ?

//Tony
 
K

Konrad Neitzel

Hi Tony!

I just wonder this part of the text above *predefined location in the
configuration file where they need to be placed*
What does that mean ?
I mean a predefined place where is that ? In the beginning at the end
or what ?

The configuration file is an XML File with a predefined structure.

And predefined location for connection Strings is:
<configuration>
<configSections>
<connectionStrings>
<add name="whatever" connectionString="Data Source=(local);Initial
Catalog=MyDB;Integrated Security=True" />
</connectionStrings>
</configSections>
</configuration>

Normaly, a XML file has to follow a special syntax that can also be
checked with xsd files just to make sure, that it is valid. I never
tried to read much more about this, but what I see quickly is, that the
xsd Files in ...\Visual Studio 9.0\XML\Schemas\DotNetConfig*.xsd look
very promising to hold the rules for the app.config file.

To read mor about XML and XSD:
http://www.w3.org/XML/
http://www.w3schools.com/Schema/default.asp
http://www.w3schools.com/Schema/schema_elements_ref.asp

Hope this helped a little.

With kind regards,

Konrad
 
T

Tony Johansson

Konrad Neitzel said:
Hi Tony!



The configuration file is an XML File with a predefined structure.

And predefined location for connection Strings is:
<configuration>
<configSections>
<connectionStrings>
<add name="whatever" connectionString="Data Source=(local);Initial
Catalog=MyDB;Integrated Security=True" />
</connectionStrings>
</configSections>
</configuration>

Normaly, a XML file has to follow a special syntax that can also be
checked with xsd files just to make sure, that it is valid. I never tried
to read much more about this, but what I see quickly is, that the xsd
Files in ...\Visual Studio 9.0\XML\Schemas\DotNetConfig*.xsd look very
promising to hold the rules for the app.config file.

To read mor about XML and XSD:
http://www.w3.org/XML/
http://www.w3schools.com/Schema/default.asp
http://www.w3schools.com/Schema/schema_elements_ref.asp

Hope this helped a little.

With kind regards,

Konrad

Hi!

I now xml and xsd.

When I look at where these two sections connectionStrings and appSettings
have been placed in the application configuration file it seems to me that
they must be placed below the <configuration> element and they are siblings
meaning they are on the same level.
I assume that it was this that the book meant with the predefined location
in the configuration file.
Don't you think so ?

//Tony


//Tony
 
K

Konrad Neitzel

Hi Tony!

When I look at where these two sections connectionStrings and
appSettings have been placed in the application configuration file it
seems to me that they must be placed below the <configuration> element
and they are siblings meaning they are on the same level.
I assume that it was this that the book meant with the predefined
location in the configuration file.
Don't you think so ?

Yes, the text gives the information, that connectionString and
applicationSettings are on the same level.

And the other sentence I simply understand this way: "Because the
connection strings are handled differently to settings, they have to be
put into their own region."

And when I was writing the text, I was simply makeing a dumb error (Just
saw it now!):

The app.config has configuration as root, which was correct. Then inside
is a configSections. But this does not include connectionStrings!

The hirarchy can be like this:
<connection>
<configSections />
<connectionString />
<applicationSettings />
...
</connection>

Sorry for this error. I hope that I didn't confuse anyone.

With kind regards,

Konrad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top