app config file

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.
 
A

Anders Borum

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top