Database Connection Setting

Topics: Data Access Application Block
Aug 13, 2013 at 7:48 PM
I have a windows service and a web application.
Web Application uses Enterprise Lib 5.0 to connect to database and executes successfully.

When i access the Getdata code of Web App from windows service i get below error:
"Activation error occured while trying to get instance of type ......"

I tried adding Enterprise Data Block Dll to windows service and set connection string in its app.config which gives error as:
"Cofiguration system failed to initialize"

Please let me know how can i resolve this
Aug 14, 2013 at 5:13 AM
Edited Aug 14, 2013 at 5:13 AM
The message "Cofiguration system failed to initialize" indicates that the config file is not valid. The web application will use web.config while the service will need the same configuration placed in app.config (and deployed as servicename.exe.config).

The config file for data access might look like:
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    <dataConfiguration defaultDatabase="Connection String" />
        <add name="Database Connection String" connectionString="Database=Database;Server=(local)\SQLEXPRESS;Integrated Security=SSPI"
            providerName="System.Data.SqlClient" />
Although if not using a default database, then connectionStrings section will suffice. Also, at runtime the applicable Enterprise Library assemblies will have to resolvable. Those would be:


Randy Levy
Enterprise Library support engineer
Support How-to