[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

AppSettingsReader.. don't work ;-

Lloyd Dupont

9/13/2003 11:32:00 PM

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 ?


3 Answers

Pawan

9/14/2003 12:06:00 AM

0

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.


"Lloyd Dupont" <net.galador@ld> wrote in message
news:uCz078keDHA.2432@TK2MSFTNGP09.phx.gbl...
> 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

9/14/2003 12:37:00 AM

0

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.




"Lloyd Dupont" <net.galador@ld> wrote in message
news:uCz078keDHA.2432@TK2MSFTNGP09.phx.gbl...
> 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 ?
>
>


Lloyd Dupont

9/18/2003 3:40:00 AM

0

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 ?

"Pawan" <pawan_atl@hotmail.com> wrote in message
news:eNU4XhleDHA.3268@tk2msftngp13.phx.gbl...
> 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.
>
>
>
>
> "Lloyd Dupont" <net.galador@ld> wrote in message
> news:uCz078keDHA.2432@TK2MSFTNGP09.phx.gbl...
> > 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 ?
> >
> >
>
>