Normally when using a DLL you would configure not the DLL but in the project you use the DLL.
To explain lets assume you have a DLL which you reuse in two executable projects. Project B references project A, and project C references project A. project A is in this case the DLL and project B and project C are executables. Lets further assume that project A uses an config setting but that actual value needs to be different for both project B and project C.
What you do in this case is to specify the settings needed by the dll in the application configuration of exe B and exe C. Also note that when the application is deployed the configuration may be different again.
To show how to include the configuration of the DLL in the application configuration i created the following. Most important is how the namespaces are used in the final app.config.
class lib
namespace ClassLibrary1
{
public class Class1
{
public string Message()
{
return Settings.Default.Message;
}
}
}
console app
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(new Class1().Message());
Console.WriteLine(Settings.Default.Message);
Console.ReadKey();
}
}
}
Configuration of Console App
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ConsoleApplication3.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="ClassLibrary1.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<ConsoleApplication3.Properties.Settings>
<setting name="Message" serializeAs="String">
<value>Hello from application</value>
</setting>
</ConsoleApplication3.Properties.Settings>
<ClassLibrary1.Properties.Settings>
<setting name="Message" serializeAs="String">
<value>Hello from DLL</value>
</setting>
</ClassLibrary1.Properties.Settings>
</applicationSettings>
</configuration>
Running this application using the dll will show the following output
Hello from DLL
Hello from application
I hope this helps.