for this config file:
//--------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Lion's Port"
value="1971"/>
</appSettings>
</configuration>
//--------
the following call work:
string sPort = ConfigurationSettings.AppSettings.Get("Lion's Port");
but this one fail:
object port = new AppSettingsReader().GetValue("Lion's Port", typeof(int));
with the error: the key 'Lion's Port' doesn't exist in the appSettings
section
what's wrong ?
Pawan - 14 Sep 2003 01:05 GMT
Hi Lloyd,
I presume that the problem is with the key name "Lion's Port". Just
check with some other string which doesnt have any " ' " in the key name.
The code looks perfect.
Pawan.
> for this config file:
> //--------
[quoted text clipped - 17 lines]
>
> what's wrong ?
Pawan - 14 Sep 2003 01:37 GMT
Lloyd,
I tried to use this and it absolutely works fine .....
object port = new AppSettingsReader().GetValue("Lion's Port",
typeof(int));
imageDescription.Text = port.ToString();
Cheers ..
Pawan.
> for this config file:
> //--------
[quoted text clipped - 17 lines]
>
> what's wrong ?
Lloyd Dupont - 18 Sep 2003 04:40 GMT
it did, mmhh.....
have to try again.... (I reboot since, that might be a reason)
I don't understand !
do you have some [STAThrea] attribute on your main ?
> Lloyd,
> I tried to use this and it absolutely works fine .....
[quoted text clipped - 28 lines]
> >
> > what's wrong ?
javierdotnet martinez - 14 Jan 2005 11:48 GMT
try with this :
/*
Replace "()" with "[]"
*/
string sPort = ConfigurationSettings.AppSettings.Get["Lion's Port"];