Problem in reading configuration file from Class library project

Posted by Newbie on Stack Overflow See other posts from Stack Overflow or by Newbie
Published on 2010-05-03T08:09:26Z Indexed on 2010/05/03 8:18 UTC
Read the original article Hit count: 169

Filed under:

If I create an app.config file in a console apps like this

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key ="key1" value ="val1"/>     
  </appSettings>
</configuration>

and access the same from the console application like

object sourcePath = System.Configuration.ConfigurationManager.AppSettings["key1"];

or by

object sourcePath = System.Configuration.ConfigurationSettings.AppSettings["key1"];

I am able to get the value.

But if I do the same thing in a class library project, I am getting a null value. Why? Where I am making mistake? I have added the proper reference System.Configuration. I am using C# 3.0

© Stack Overflow or respective owner

Related posts about c#3.0