AppSettingsReader.. don't work ;-(

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

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 ?
 
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,
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.
 
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 ?
 
Back
Top