How Use SQL CE as Backing Store for Caching Application Block

Topics: Building and extending application blocks, Caching Application Block , Data Access Application Block
Jul 25, 2008 at 8:00 PM
Edited Jul 25, 2008 at 8:05 PM
Hi,

I am trying to use SQL CE 3.5 as Backing Store for CAB. I have added Configuration, code and references in my project so that I can start using Caching Application Block with SQL CE as backing store. But I am getting the following error and I am really not sure where exactly I can fix this. I have appended the code, config, references below,

The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager, Metropolis]) failed: The CommandType enumeration value, 1, is invalid. (Strategy type Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2)

I am getting this error at the following code,

ICacheManager 

 

cacheManager = CacheFactory.GetCacheManager("Metropolis"); 

using Microsoft.Practices.EnterpriseLibrary.Caching;
using Microsoft.Practices.EnterpriseLibrary.Caching.Expirations; 
using Microsoft.Practices.EnterpriseLibrary.Common; 
using Microsoft.Practices.ObjectBuilder2;

Could anyon please guide me about how I can use Caching Application Block with SQL CE as my backing store? Any help would be greatly appreciated. 

Referenced Assemblies:
Microsoft.Practices.EnterpriseLibrary.Caching
Microsoft.Practices.EnterpriseLibrary.Caching.Database
Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.EnterpriseLibrary.Data
Microsoft.Practices.EnterpriseLibrary.Data.SqlCe
Microsoft.Practices.ObjectBuilder2

My Configuration:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </configSections>
  <dataConfiguration defaultDatabase="CEConnection" />
  <connectionStrings>
    <add name="CEConnection" connectionString="Data Source=C:\\Users\\vebhupat\\AppData\\Local\\Metropolis\\CacheData.sdf;Persist Security Info=True"
      providerName="System.Data.SqlServerCe.3.5" />
  </connectionStrings>
  <cachingConfiguration defaultCacheManager="Metropolis">
    <cacheManagers>
      <add expirationPollFrequencyInSeconds="600" maximumElementsInCacheBeforeScavenging="500"
        numberToRemoveWhenScavenging="10" backingStoreName="Data Cache Storage"
        type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Metropolis" />
    </cacheManagers>
    <backingStores>
      <add databaseInstanceName="CEConnection" partitionName="Part1"
        encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Database, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Data Cache Storage" />
    </backingStores>
  </cachingConfiguration>
</configuration>

Dec 17, 2008 at 6:14 AM
Hi,

I am facing the same issue.

It seems the EntLib does not have built in support for SqlCe as a backing store for caching application block.

http://huntjason.spaces.live.com/blog/cns!9D2E96F2AA6AE85F!440.entry

Regards,
Kapil


Dec 17, 2008 at 7:29 AM
There is no out-of-the-box support for this.

Caching Application Block - Selecting a Backing Store
"Developers can use other database types as backing stores, but they must modify the application block source code."


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