views:

49

answers:

2

Hi!

I got a solution that includes 3 different projects, a Class Library, a Web Service and a Windows Service.

MySolution.DataAccessLayer (Class Library)

Using Entity-Framework 3.5 to access the database.

MySolution.WebService (Web Service)

MySolution.WindowsService (Windows Service)

My problem is that a have to include the Connection String in my Web Service/Windows Service configuration files to get it to work.

I have checked and I have the correct Connection String in my DataAccessLayer App.Config.

Why does it not use that?

+4  A: 

It will not run that, because the DLL is loaded in the process space. Meaning that the services load the DLL and it is the service config that is used.

In other words - the service starts, loads the config file (that belongs to it), then loads the dataaccess DLL. As it already has its own config, it will not look further for the DLL config.

Oded
To add, it is explicitely APPLICATION config - a linked DLL is a library, not the application.
TomTom
A: 

The config system looks up the app/web.config for the app that's running, regardless of where in the code you look up the configuration.

The class library doesn't care that it's a class library/seperate .dll when it's running, and will just look up configuration in the app.config for the program that's running - which will be the config for your Windows service in one case and the config for your Web service in the other.

nos