Activation error occured while trying to get instance of type ICacheManager, key ""

Topics: Caching Application Block
Jul 27, 2011 at 2:53 PM

I am using Ent Lib 5.0 with WCF Service Library (.NET 4).
When using the DAAB, I got this error 'Activation error occurred while trying to get an instance of type Database, key'.

My Cenario:

  • WCF (Config File) -> Business -> Data (Base and Caching Base)

Error: Activation error occured while trying to get instance of type ICacheManager, key ""

Error ocorred in this method:
 public class Caching<O> where O : new()    {

        static ICacheManager cacheData;

public static List<O> GetData(string cacheName){

cacheData = EnterpriseLibraryContainer.Current.GetInstance<ICacheManager>();

        List<O> lstEntity = null;lstEntity = (List<O>)cacheData[cacheName];        
        return lstEntity;
}....

WenConfig (on WCF):
<configuration>
  <configSections>
    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>
  <enterpriseLibrary.ConfigurationSource selectedSource="System Configuration Source">
    <sources>
      <add name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null" />
    </sources>
  </enterpriseLibrary.ConfigurationSource>
  <cachingConfiguration defaultCacheManager="Cache Manager">
    <cacheManagers>
      <add name="Cache Manager" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"          expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000"          numberToRemoveWhenScavenging="10" backingStoreName="NullBackingStore" />
    </cacheManagers>
    <backingStores>
      <add type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"          name="NullBackingStore" />
    </backingStores>
  </cachingConfiguration> 

 

Help me LOL!!!!

Sincerely.. Pablo Andréi

Jul 28, 2011 at 7:56 AM

Hi,

I'm kind of confused of your issue. Are you getting two seperate exceptions? Activation error from Database and another from Caching? If this is the case, then based on your configuration, you should add your database application block settings.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us