Creating production, testing, and development connection strings for a DLL
Posted on 2008-10-17
I'm developing a site using Visual C# 2008. I have a solution with the following projects:
Business Logic Layer (BLL)
Data Access Layer (DAL)
When I publish the website, the BLL and DAL are compiled into DLLs, and placed in the bin directory of the website.
I want to have the DAL use different connection strings when I deploy the application to development, testing, and production environments. Right now, though, the settings in app.config file for the DAL are embedded into the DLL when it's compiled, rather than read from an external file.
While one could obviously switch all the settings to the production settings before publishing the site, this introduces a high likelihood of error (leaving the development settings on in prod, using production settings in dev, etc). I'd like to have the DAL read its configuration settings in its deployment environment.
How best to do this?