Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / January 2005

Tip: Looking for answers? Try searching our database.

AppSettingsReader.. don't work ;-(

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lloyd Dupont - 14 Sep 2003 00:31 GMT
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"];

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.