I have searched the site, and while I found some very useful information, I couldn\'t figure out what is going on with my code. I have the following web.config:
I bet u r using the right syntax to access them when you write: ConfigurationManager.AppSettings["Key1"];
Try this format for the web config
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="Key1" value="Val1"/>
<add key="Key2" value="Val2"/>
</appSettings>
<connectionStrings>
......
......
</connectionStrings>
<system.web>
<sessionState mode="InProc" timeout="20"/>
<authorization>
......
</authorization>
<pages>
<namespaces>
<add namespace="System.Data"/>
<add namespace="System.Data.SqlClient"/>
<add namespace="System.IO"/>
</namespaces>
</pages>
<customErrors mode="Off"/>
<compilation debug="true"/></system.web>
</configuration>
i have two project in my solution first i add app.config file in class library project which all instances is call from console application i added these entries in config file in class lib project
<appSettings>
<add key="userName" value="user2" />
<add key="emilsLimit" value="50" />
</appSettings>
it was throwing null exception when i get these in a class in class library project but when i delete app.config from class Library project and added in Console project it works.Cheers
Note: Class lib project reference is added in console