ResolutionFailedException: Resolution of the dependency failed... The type Database cannot be constructed

Topics: Enterprise Library Core
Mar 27, 2014 at 5:46 PM
Hello,

Thank you for reviewing my question. First, I am a novice with Enterprise Library. I updated an existing program to .NET 4.0, Visual Studio 2013 and to a new version of the Enterprise Library v5.0 (previously used 4.0).

I can run the VB website without any issue on my desktop but when I deploy it to our Windows Server 2003 I get the following errors. I installed .NET 4.0 and the Enterprise Library 5.0 onto the server but get the error message.

ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Data.Database", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type Database cannot be constructed. You must configure the container to supply this value.

My 'web.config' file contains the following:

<configuration>
<configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true"/>
    <section name="oracleConnectionSettings" type="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.Configuration.OracleConnectionSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true"/>
</configSections>
<dataConfiguration defaultDatabase="OracleTP">
    <providerMappings>
        <add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Oracle.ManagedDataAccess.Client"/>
    </providerMappings>
</dataConfiguration>
<oracleConnectionSettings>
    <add name="OracleTP"/>
</oracleConnectionSettings>

<connectionStrings>
    <add name="OracleTP" connectionString="User ID=xxxx;Password=xxxxxxxx; Data Source=xxxxxxxx:24106/xxxxxx; Pooling=false;" providerName="Oracle.ManagedDataAccess.Client"/>
    <add name="OracleEbiz" connectionString="User ID=xxxx;Password=xxxxxxxx; Data Source=xxxxxxxx:24101/xxxxxx; Pooling=false;" providerName="Oracle.ManagedDataAccess.Client"/>
</connectionStrings>
</configuration>

I would appreciate any suggestions.

Many Thanks
Peter
Mar 31, 2014 at 6:53 AM
It could be that the DbProviderFactories are not configured on the target server. On your desktop they were probably added to the machine config. Perhaps on the server they were not added to the machine.config? The machine.config should have something like this:
<system.data>
  <DbProviderFactories>
    <add name="Oracle Managed Data Provider for .NET" invariant="Oracle.ManagedDataAccess" description="Oracle Managed Data Provider for .NET" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.112.3.50, Culture=neutral, PublicKeyToken=89b483f429c47342" />
  </DbProviderFactories>
</system.data>
I'm not sure what the actual version number should be (but you should be able to tell from your development machine -- assuming the same version is being used everywhere). Also, make sure you check the 32 and 64 bit machine.config.

Another alternative would be to just add the DbProviderFactory to the web.config:
<system.data>
  <DbProviderFactories>
    <remove invariant="Oracle.ManagedDataAccess" />
    <add name="Oracle Managed Data Provider for .NET" invariant="Oracle.ManagedDataAccess" description="Oracle Managed Data Provider for .NET" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.112.3.50, Culture=neutral, PublicKeyToken=89b483f429c47342" />
  </DbProviderFactories>
</system.data>
~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to