views:

20

answers:

1

I have a website project which includes several assemblies which are built separately. One of the assemblies is the EntityModel, which also has an app.config file with the connection string to the database.

The website project then brings that DLL into its own project. When I build the website assembly, I just copy the website folder to the server. The web.config connection string has a different database name on the live server, so I change that on the server and works fine.

However, the assembly which is included into the website project has already been built with a connection string that refers to my local DB name, not the production DB name.

What I would like to know is how do I ensure the assembly is using the correct DB connecting string in the app.config as it won't have 'visibility' of the changed DB name in the web.config.

I might be wrong but it seems the connection will be baked into the assembly which I don't want.

+3  A: 

The app.config of the data assembly will be ignored, and the web.config will be used. Config settings come from the executing assembly.

Craig Stuntz
And in the case of a web site, the "executing assembly" config is web.config, not app.config.
GalacticCowboy
Great, that explains clearly what is going on. I guess the app.config would be used if NUnit runner was exercising tests on it because the assembly is then isolated.
Jon