I’m trying to pull an email address from the appSettings section of the app.config file. Every time I run a test, reportRecipients is Null. Can anyone see what I’m doing wrong?
<appSettings>
<add key="Overdue_Report_Recipients" value="myemail@email.com"/>
</appSettings>
string reportRecipients = ConfigurationManager.AppSettings["Overdue_Report_Recipients"];
Thanks
Edit:
this is for a project that is not a web app. It’s part of a Solution where most of the projects are web apps but this particular one is a service. sorry for the confusion with asp.net tag i have removed it.
I have another value stored in app Settings and I’m able to get the data from it
<add key="Sweeper_Notify_When_None_Overdue" value="false"/>
bool sendWhenNoneOverdue =
Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["Sweeper_Notify_When_None_Overdue"]);
ANSWER:
I was running my test in a separate project and the test was reading from the config file in the test project and not the app.config in the project I was testing.
I had to copy the settings to the config in the test project and then the test worked.
I was running my test in a separate project and the test was reading from the config file in the test project and not the app.config in the project I was testing. I had to copy the settings to the config in the test project and then the test worked.