Activate Exception Caught

Topics: Data Access Application Block
May 5, 2010 at 4:30 PM

Hi

am using  entlib 5.0 with .net 4.0, when i try to acess the database, it throws an exception as 

"Activation error occured while trying to get instance of type Database, key """. Please help to resolve, I need to fix asap.

 

Regards,

Thiru.

May 5, 2010 at 6:04 PM

That typically means that the data block isn't configured properly. Have you defined a default database in your configuration file?

 

May 5, 2010 at 6:25 PM

Please find my configuration file settings.

<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="HDSDB">
</dataConfiguration>

<connectionStrings>
<add name="HDSDB" connectionString="Data Source=XXXXX;Initial Catalog=XXXX; Integrated security=true" providerName="System.Data.SqlClient" />
</connectionStrings >

</configuration>


"ctavares" <notifications@codeplex.com>

05/05/2010 11:04 AM

Please respond to
entlib@discussions.codeplex.com

To
thiru_masilamani@ahm.honda.com
cc
Subject
Re: Activate Exception Caught [entlib:211672]





From: ctavares

That typically means that the data block isn't configured properly. Have you defined a default database in your configuration file?

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

May 6, 2010 at 12:14 AM

Can you post your code as well?  In addition, are you referencing the Data assembly from GAC?

 

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

May 6, 2010 at 3:39 PM

Hi,

thanks for your reply, I have fixed the issue, I was not using the parent project app.config, that was the issue.

thanks,
thiru.
Aug 2, 2010 at 5:26 PM

I am having the same problem.   Not sure what goes wrong.   Would you take a look into this?

 

Here is my App.config file:

<?xml version="1.0" encoding="utf-8" ?>
<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="TEST" />
    <connectionStrings>
        <add name="TEST" connectionString="Data Source=CB826832;Initial Catalog=myDBTest;Integrated Security=SSPI;"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
</configuration>

 

 

In my BLL file, I have this line of code:

 

Database db = DatabaseFactory.CreateDatabase();

 

It gets an error as Activation error occured while trying to get instance of type Database, key """

 

My solution has two projects:  One for all the classes (which are BLL methods), the other project is regular web project.  In this web project, I reference to the other project dlls.   They are very straight forward.  Not sure why it bombs out.

Environments:  VS2010 | SQL server2008 | Enterprise Library 5.0

Thank you much for your help.

le9569

Aug 2, 2010 at 5:40 PM

Interesting finding is:  I have to configure the web.config in the client project as well.   The configuration in App.Config doesn't do any good.....  After applying that block of codes in both places, it works.

Not sure why but hey, it works.

I hope this helps someone who gets in the same problem.

Bests

le9569

Aug 3, 2010 at 3:12 AM

This is actually because your client project is a web project (as mentioned from the initial post) therefore it'll indeed require entlib configuration to be put in the web app's web.config.

While as for app.config it is only applicable to either winforms or console application only. Hope this helps validates your findings :-)

Gino Terrado
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com