Hello,
i have a config file like this:
?xml version="1.0" encoding="utf-8" ?
configuration
appSettings
add key="PortName" value="COM4"
add key="BaudRate" value="9600"
add key="DataBits" value="8"
appSettings
configuration
... and then i want to access app.config values with this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
using System.Configuration;
namespace SystemToControler
{
public class ConnectionProtocol : IConnectionProtocol
{
SerialPort serialPort = new SerialPort();
public ConnectionProtocol()
{
serialPort.PortName = ConfigurationManager.AppSettings["PortName"];
serialPort.BaudRate = Convert.ToInt32(ConfigurationManager.AppSettings["BaudRate"]);
serialPort.DataBits = Convert.ToInt32(ConfigurationManager.AppSettings["DataBits"]);
}
}
}
... and it tells me i that those keys does not exist.
What am i doing wrong??? Please help!