Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

ConfigurationManager.AppSettings not reading my app.config

$
0
0
I am having a frustrating issue that everyone tells me should be very simple to execute.
I'm using the new ConfigurationManager object from System.Configuration.dll which I have referenced in my project.  I do not have any compliation problems or warnings, yet I cannot get a single key value out of my app.config file.  My config file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <appSettings>
    <add key="KeyName" value="KeyValue"/>
  </appSettings>
</configuration>

and am trying to just assign this to a string like this:

string path =  System.Configuration.ConfigurationManager.AppSettings["KeyName"];

not only does this invariably result in an empty string, but also when I step to this line in my code...System.Configuration.ConfigurationManager.AppSettings.AllKeys evaluates to {Dimensions:[0]} as if I don't even have an App.Config file.  What could I possibly be doing wrong!?!?!?!



Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>