EL 5.0 Caching block with SQL CE 4.0 , activation error!

Topics: Caching Application Block
Nov 16, 2012 at 6:06 AM

I am getting following error when I am trying to use an SQL CE 4.0 database as a backing store for caching block.

 

The exception is " {"Activation error occured while trying to get instance of type ICacheManager, key \"Cache Manager\""}

The message is as follows:

Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager", name = "Cache Manager".Exception occurred while: Calling constructor Microsoft.Practices.EnterpriseLibrary.Caching.Cache(Microsoft.Practices.EnterpriseLibrary.Caching.IBackingStore backingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Instrumentation.ICachingInstrumentationProvider instrumentationProvider).Exception is: ArgumentException - The CommandType enumeration value, CommandType.StoredProcedure, is invalid.-----------------------------------------------At the time of the exception, the container was:
  Resolving Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager,Cache Manager (mapped from Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager, Cache Manager)  Resolving parameter "realCache" of constructor Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager(Microsoft.Practices.EnterpriseLibrary.Caching.Cache realCache, Microsoft.Practices.EnterpriseLibrary.Caching.BackgroundScheduler backgroundScheduler, Microsoft.Practices.EnterpriseLibrary.Caching.ExpirationPollTimer pollTimer)    Resolving Microsoft.Practices.EnterpriseLibrary.Caching.Cache,Cache Manager    Calling constructor Microsoft.Practices.EnterpriseLibrary.Caching.Cache(Microsoft.Practices.EnterpriseLibrary.Caching.IBackingStore backingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Instrumentation.ICachingInstrumentationProvider instrumentationProvider)

The stack trace for the exception is :

   at System.Data.SqlServerCe.SqlCeCommand.set_CommandType(CommandType value)   at Microsoft.Practices.EnterpriseLibrary.Data.Database.CreateCommandByCommandType(CommandType commandType, String commandText) in e:\Builds\EntLib\Latest\Source\Blocks\Data\Src\Data\Database.cs:line 319   at Microsoft.Practices.EnterpriseLibrary.Data.Database.GetStoredProcCommand(String storedProcedureName) in e:\Builds\EntLib\Latest\Source\Blocks\Data\Src\Data\Database.cs:line 1238   at Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore.LoadDataFromStore() in e:\Builds\EntLib\Latest\Source\Blocks\Caching\Src\Database\DataBackingStore.cs:line 160   at Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.BaseBackingStore.Load() in e:\Builds\EntLib\Latest\Source\Blocks\Caching\Src\Caching\BackingStoreImplementations\BaseBackingStore.cs:line 157   at Microsoft.Practices.EnterpriseLibrary.Caching.Cache..ctor(IBackingStore backingStore, ICachingInstrumentationProvider instrumentationProvider) in e:\Builds\EntLib\Latest\Source\Blocks\Caching\Src\Caching\Cache.cs:line 46   at BuildUp_Microsoft.Practices.EnterpriseLibrary.Caching.Cache(IBuilderContext )   at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\DynamicMethod\DynamicMethodBuildPlan.cs:line 37   at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\BuildPlanStrategy.cs:line 43   at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\StrategyChain.cs:line 110   at Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\BuilderContext.cs:line 220   at Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilderCustomization\NamedTypeDependencyResolverPolicy.cs:line 51   at BuildUp_Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager(IBuilderContext )   at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\DynamicMethod\DynamicMethodBuildPlan.cs:line 37   at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\BuildPlanStrategy.cs:line 43

My app configuration is :

<?xml version="1.0"?>
<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" />
		<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>
	<dataConfiguration defaultDatabase="SFCacheConnection" />
	<connectionStrings>
		<add name="SFCacheConnection" connectionString="Data Source=SFCache.sdf"
            providerName="System.Data.SqlServerCe.4.0" />
	</connectionStrings>
	<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="Data Cache Storage" />
		</cacheManagers>
		<backingStores>
			<add name="Data Cache Storage" type="Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                encryptionProviderName="" databaseInstanceName="SFCacheConnection"
                partitionName="SFCachePartition" />
			<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>
	<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
	
</configuration>

The ".sdf" db is added as "Content" " Do not copy" properties.

 

Can you help me out please ??

Thanks,

Aseem Chiplonkar

 

Nov 16, 2012 at 9:50 AM

The key message in the stack trace is:  ArgumentException - The CommandType enumeration value, CommandType.StoredProcedure, is invalid.

The default DataBackingStore uses stored procedures to implement the functionality however SQL CE does not support stored procedures.  If you want to use SQL CE as a backing store you will have to create a new backing store that incorporates the stored procedure logic.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com