If the type cannot be found, one or both of 2 things is happening. Either
you haven't referenced the assembly (DLL), or you haven't added a using
statement to negate the necessity of using the complete NameSpace
hierarchy
in your code. The complete NameSpace for NameValueCollection is
"System.Collections.Specialized.NameValueCollection".
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
I have to admit this is far beyond my knowledge so I just try to copy
&
paste with some common sense... so far I've got the xml file correct but
NameValueCollection sampleConfig =
(NameValueCollection)ConfigurationSettings.GetConfig("mySectionGroup/myWeb1"
);
string strKeyValue = (string)sampleConfig["Title"];
myLabel.Text = myVar;
just brings on an error (surprise): "The type or namespace name
'NameValueCollection' could not be found (are you missing a using
directive
or an assembly reference?)"
Correct. Remember I mentioned that you can create your own
customized
Sections? That's what you need here. See the following SDK article for
more
information about how:
http://msdn.microsoft.com/library/d.../cpguide/html/cpcondeclaringsectiongroups.asp
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
Kevin, so far so good but .Net doesn't allow me to split the
appsettings
into subgroups eg
<appSettings>
<Web1Group>
<add key="Title" value="Title of web 1"/>
...
</Web1Group>
<Web2Group>
<add key="Title" value="Title of web 2"/>
...
</Web2Group>
</appSettings>
The error I get: "Unrecognized element."
My apologies, David.
After re-reading your question and my response, I can see that I was
not
answering the question you asked, which is how to read data
stored
in
an
XML
file INTO memory, which is something altogether different from
storing
XML
data IN memory. Reading it from a file is a great idea, as
exemplified
by
the use of XML for the web.config and other configuration files that
ASP.Net
and .Net in general uses.
In fact, using the web.config file might be your best bet to
begin
with.
You
can easily use the built-in "appSettings" element in the web.config
to
define your own data, which can easily be read from the file at run
time.
Example:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString"
value="server=blah;uid=Blah;pwd=blahblah;database=blah"/>
<add key="VoyagerPath" value="C:\VoyagerOnline" />
<add key="Timeout" value="15" />
</appSettings>
...
These configuration elements are easy to fetch at run-time. Example:
Dim Timeout As int =
System.Configuration.ConfigurationSettings.AppSettings("Timeout")
You can also define custom configuration sections, if you have a lot
of
data
and need to organize it into a nice tree hierarchy.
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
now in my web I have some global variables to be used in many
different
subpages, in the old ASP I simply loaded a variables.asp file into
memory
using the eval() function. Now I'd like to use XML but what method
would
I
use to load the entries from the xml file into memory and make them
quickly
accessible globally in the web code? Just need to know what
functions
specifically I should start reading about!
Thx