Nov 30, 2011 01:13 AM|raringsunny|LINK
I am working on an ASP.Net website where I have used the layered architecture approach.
I have a separate layer for Data Access, Business logic, Presentation etc.
I get the following error when trying to use Enterprise Library Data Access app block.
The type Database cannot be constructed. You must configure the container to supply this value.
After researching on net, I found out that to fix the problem the connection string needs to be supplied to the CreateDatabase class construcor as shown in the statement below.
Database db = DatabaseFactory.CreateDatabase("<Connection
string from config file>");
The afore-mentioned code would typically be part of Data access layer (which is a separate class library project).
How the Data access layer should read the configuration information being a class library project? Usually, the web.config file exists in the Web application project.
Should we have an app.config file in the Data access library project or which other way configuration information (connection string) can be read from a config file from a data access library project?
data access layer