C#C
C#17mo ago
NovemberRains

ConfigurationManager return null instead of string values

In my NUnit project framework, I am using ConfigurationManager.AppSettings["Company"] to read a value from the App.config file which is stored in my working directory, but the value returned is always null, even though the key exists and it has a value, Does any one know why?

App.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Company" value="0000" />
</appSettings>
</configuration>

And I try to get;

var companyValue = ConfigurationManager.AppSettings["Company"];

I've also set the 'Build Action' to 'None' and 'Copy to Output Directory' to 'Copy Always'
Was this page helpful?