Why is this class library dll not getting information from app.config

Posted by baron on Stack Overflow See other posts from Stack Overflow or by baron
Published on 2010-06-01T00:16:05Z Indexed on 2010/06/01 0:23 UTC
Read the original article Hit count: 614

I am developing a custom HttpHandler, to do so I write a C# Class Library and compile to DLL.

As part of this I have some directory locations which I want not hard coded in the app, so i'm trying to put it in the app.config which I've used before.

Before this has worked by just going building the app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="Share" value="C:\...\"/>
  </appSettings>
</configuration>

And then obtaining this in code like:

var shareDirectory = ConfigurationManager.AppSettings["Share"];

But when I compile it and put it in the bin folder for the webservice, it keeps getting null for shareDirectory, probably because it can't find app.config. So how do I make sure this is included so I don't have to hard code my direcotry locations? I notice it will essentially after compiled we get the assembly.dll and the assembly.dll.config which is the app.config file, so it's definetly there in the bin folder!

© Stack Overflow or respective owner

Related posts about dll

Related posts about httphandler