DatabaseFactory.CreateDatabase() InvalidOperationException: The type Database cannot be constructed. You must configure the container to supply this value

Topics: Data Access Application Block
Apr 12, 2011 at 2:31 PM

Hello i'm geting this error on live production server but it works on development envirenment.

 

What can it be? i don't want to go all over the code to add a connection string? is this a bug? or i need to publish the dll on gac?

 

i have the configuration set in my web config...

Apr 13, 2011 at 3:03 AM

Hi,

You need to check on the following:

  1. Make sure your database connection strings are defined in your executable project’s configuration file.
  2. If you’re resolving a default Database instance, make sure that you set the Default Database property of the Database Settings.
  3. If you’re not resolving a Database instance, check if the providerName attribute of the connection string you’re using is properly set. It should be the correct type name. For example, if your connection string is a SQL connection string, it should be System.Data.SqlClient instead of just SqlClient. Use the Enterprise Library Configuration Tool to simplify this task and avoid mistyping.
  4. If you’re resolving a custom database provider, make sure that your custom database’s provider factory has a corresponding entry in your machine.config’s <system.Data><DbProviderFactories> section.
  5. There’s an issue when referencing the Microsoft.Practices.EnterpriseLibrary.Data assembly from GAC.   This is listed in the Enterprise Library 5.0 Known Issues and logged in the Issue Tracker. For the details and  workaround, refer to this link.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 15, 2011 at 2:14 PM
Hello Noel,

First of all I'm not using the gac dll's.

I'm using the bin dll's.

Second i have made the configuration through Entreprise Library configuration tool so the provider tag is well formed and no i'm not using a custom provider i'm using the System.Data.SqlClient provider.


My web site is a asp.net mvc application and i'm usind a default database.

this is my configuration

<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" />

</configSections>

<dataConfiguration defaultDatabase="x3" />
<connectionStrings>
<add name="x3" connectionString="Data Source=*****\*****;Inicial Catalog=***;User ID=*****; Password=******" providerName="System.Data.SqlClient"/>
</connectionStrings>

And i'm getting this error.

System.InvalidOperationException: The type Database cannot be constructed. You must configure the container to supply this value.

What can be?

Best Regards,

Marco Teodoro

2011/4/13 AvanadeSupport <notifications@codeplex.com>

From: AvanadeSupport

Hi,

You need to check on the following:

  1. Make sure your database connection strings are defined in your executable project’s configuration file.
  2. If you’re resolving a default Database instance, make sure that you set the Default Database property of the Database Settings.
  3. If you’re not resolving a Database instance, check if the providerName attribute of the connection string you’re using is properly set. It should be the correct type name. For example, if your connection string is a SQL connection string, it should be System.Data.SqlClient instead of just SqlClient. Use the Enterprise Library Configuration Tool to simplify this task and avoid mistyping.
  4. If you’re resolving a custom database provider, make sure that your custom database’s provider factory has a corresponding entry in your machine.config’s <system.Data><DbProviderFactories> section.
  5. There’s an issue when referencing the Microsoft.Practices.EnterpriseLibrary.Data assembly from GAC. This is listed in the Enterprise Library 5.0 Known Issues and logged in the Issue Tracker. For the details and workaround, refer to this link.

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Read the full discussion online.

To add a post to this discussion, reply to this email (entlib@discussions.codeplex.com)

To start a new discussion for this project, email entlib@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Apr 18, 2011 at 4:23 AM

Did you check if there were entlib dlls in GAC?  Was there an inner exception? 

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com