Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Dear Experts,

I am Doing an Asp.net 4.5 project, and i got an error when i used the

C#
DatabaseFactory.CreateDatabase("dataConfiguration");



Here is the Config code..

HTML
<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="false" />
</configSections>

<dataConfiguration defaultDatabase="Connection_String" />

<connectionStrings>
  <add name="Connection_String" connectionString="Data Source=MYPC;Initial Catalog=dbtest;Persist Security Info=True;User ID=sa;Password=abc_123456" providerName="System.Data.SqlClient" />
</connectionStrings>



Here is the Below Error Code
Activation error occured while trying to get instance of type Database, key "dataConfiguration"



Please Help me to Solve this issue..


Thanks and Regards,

Dileep...
Posted
Updated 3-Jan-14 5:56am
v5
Comments
Did you try some answers from links suggested by Google?

There's a mismatch in dll versions in your project for the EF dll, or you need to change the version of .NET you're targetting. At least, that's what I found out using google, I don't have any actual experience with your specific issue.
 
Share this answer
 
This is how I call DataBaseFactory

Database db = DatabaseFactory.CreateDatabase();

VB
public static Database CreateDatabase();
   //
   // Summary:
   //     Method for invoking a specified Database service object. Reads service settings
   //     from the ConnectionSettings.config file.
   //
   // Parameters:
   //   name:
   //     configuration key for database service
   //
   // Returns:
   //     Database
   //
   // Exceptions:
   //   System.Configuration.ConfigurationException:
   //     instanceName is not defined in configuration.
   //     - or -
   //     An error exists in the configuration.
   //     - or -
   //     An error occured while reading the configuration.
   //
   //   System.Reflection.TargetInvocationException:
   //     The constructor being called throws an exception.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900