app.config file mix up for .net app

I have a solution with 4 projects within that all interact with each other. Each project contains its own app.config file named as 'app.config' and may at times contain the same appsettings fields. however for some reason when calling one project.method from another, when it initializes, it calls the app.config file from the calling project method. This should not be the case since I know that each project is compiled with its own config file.

 o = streamSettings.GetValue("ConnectionString", GetType(String))
    connectionString = o.ToString()

    o = streamSettings.GetValue("LogFileDirectory", GetType(String))
    logFileDirectory = o.ToString()

This is the same for the all projects but I am getting the wrong connection string here.


Are any of the projects DLL's by chance.

.NET's config system associates the APP.CONFIG file with a PROCESS, not a executable image.

So, say you have a solution with ProjectA (an EXE) and project b (a DLL).

Project A references Project B and calls into project B.

In Project A, calls to config methods will pull from Project A's App.config.

Once Project A calls into Project b, the code in Project B will also end up refering to Project A's config file, just looking into the sections defined in Project B.

it's weird and pretty unweildy, but that appears to be intentional

There are some articles out on the web though about how to setup a DLL so that it reads from it's OWN configuration file.

Here's one from SO itself

C# Dll config file

Need Your Help

WPF control always rendered as topmost in web page

c# .net wpf

I am using ElementHost (.NET Framework 4) to host a WPF control in a web page:

JSF ui:include downside

jsf user-interface include

I have this web application and one of the module use an excessive amount of ui:include.