ConfigurationManager.AppSettings - returns zero

I am trying to read the settings from my app.config and I'm sure that it worked before that, but now it returns a nullReferenceException.

My code getting settings looks like this:

codeValueUtilRx = ConfigurationManager.AppSettings["CODEVALUE_UTIL_RX"].Split(';').ToList(); 

My app-congfig is as follows:

 <appSettings> <add key ="LOGFILELOCATION" value ="C:\\RuleEditor\\"/> <add key ="CODEVALUE_UTIL_RX" value="GCN;GRP;NDC;SPEC;TCC"/> </appSettings> 

I have a feeling, something that seems obvious, I just can not understand it. Ive tried moving app-config to different projects in the solution, and ive recreated the file, but no luck. Any ideas?

+7
c # app-config configurationmanager
source share
1 answer

Ive tried to move app-config to different projects in the solution, and ive tried to create a file, but no luck

your code is correct (I tested), you need to make sure that your app.config file is in your main project (exe).

+15
source share

All Articles