Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ConfigurationManager.AppSettings - Returns Null

Im trying to read settings from my app.config and im sure it was working before but now it returns a nullReferenceException.

My code getting the settings is as follows:

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 its something seemingly obvious, I just cant figure it out. Ive tried moving the app-config to different projects in the solution and ive recreated the file, but with no luck. Any ideas?

like image 392
Steve2056726 Avatar asked Aug 27 '13 16:08

Steve2056726


1 Answers

Ive tried moving the app-config to different projects in the solution and ive recreated the file, but with no luck

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

like image 64
Ehsan Avatar answered Nov 13 '22 15:11

Ehsan