app config file

  • Thread starter Thread starter 2G
  • Start date Start date
2

2G

Hi,

I have some trouble reading from the config file, don't know what I'm doing
wrong.

I created a config file named App.config and contains following :
<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<appSettings>

<add key="Port" value="20789" />;

</appSettings>

</configuration>


but when i try to get the port from the app config using
string tmp = System.Configuration.ConfigurationSettings.AppSettings["Port"];

i get error "Only elements allowed".

Anyone could help me out a bit ?
Thanks.
 
Hello!

You've got a text element in your configuration file. The ";" is not allowed
in the config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Port" value="20789" />; <-------- here!
</appSettings>
</configuration>
 
Back
Top