GetCacheManager Error

Topics: Caching Application Block
Oct 25, 2010 at 4:44 PM

I am using EnterpriseLibrary 2.0 with a Visual Basic 9 web services project and am getting the following error:

"Unable to find assembly 'CacheExample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null".

I call the CacheManager:

 

using System;
using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Caching.Instrumentation;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder;

'try to get the response from cache
Me.m_cacheManager = CacheFactory.GetCacheManager("CSG Cache Manager")

public static CacheManager GetCacheManager(string cacheManagerName)
{
try
{
lock (lockObject)
{
return factory.Create(cacheManagerName);  '-->Error occurs here!!!
}
}
catch (ConfigurationErrorsException configurationException)
{
TryLogConfigurationError(configurationException, cacheManagerName);
throw;
}
}

 I will paste the entire error message:

<Exception><Type>System.Runtime.Serialization.SerializationException</Type><Message>Unable to find assembly 'CacheExample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.</Message><StackTrace>   at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()

   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)

   at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)

   at System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create(String name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)

   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)

   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)

   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()

   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)

   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)

   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)

   at Microsoft.Practices.EnterpriseLibrary.Caching.SerializationUtility.ToObject(Byte[] serializedObject)

   at Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore.DeserializeValue(DataRow dataToLoad)

   at Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore.CreateCacheItem(DataRow dataToLoad)

   at Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore.LoadDataFromStore()

   at Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.BaseBackingStore.Load()

   at Microsoft.Practices.EnterpriseLibrary.Caching.Cache..ctor(IBackingStore backingStore, CacheCapacityScavengingPolicy scavengingPolicy, CachingInstrumentationProvider instrumentationProvider)

   at Microsoft.Practices.EnterpriseLibrary.Caching.CacheManagerFactoryHelper.BuildCacheManager(String cacheManagerName, IBackingStore backingStore, Int32 maximumElementsInCacheBeforeScavenging, Int32 numberToRemoveWhenScavenging, Int32 expirationPollFrequencyInSeconds, CachingInstrumentationProvider instrumentationProvider)

   at Microsoft.Practices.EnterpriseLibrary.Caching.CacheManagerCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)

   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)

   at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)

   at Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)

   at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)

   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)

   at Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)

   at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)

   at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp[TTypeToBuild](IReadWriteLocator locator, String idToBuild, Object existing, PolicyList[] transientPolicies)

   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, String id, IConfigurationSource configurationSource)

   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.LocatorNameTypeFactoryBase`1.Create(String name)

   at Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.GetCacheManager(String cacheManagerName)

   at Enterprise.BillingSystem.Csg.Business.OrderBO.AddOrder(GenericRequestEnvelope`1&amp; requestEnvelope) in C:\Source\Billing System\Csg\2.06\Enterprise.BillingSystem.Csg.Business\OrderBO.vb:line 2152</StackTrace></Exception>

Oct 25, 2010 at 11:53 PM

It is definitely looking for the CacheExample assembly.  Does that assembly contains any custom provider related to caching?  Does your host project have a reference to it?

 

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

Oct 26, 2010 at 2:59 PM

There is no reference in the solution to CacheExample.  I don't know what CacheExample is.  I will see if I can create a workaround.

Thanks.

Nov 1, 2010 at 3:16 PM

I found a resolution to this error in case someone else has the problem.  The problems seems to have been in my web.config.  The web.config was pointing to the wrong databaseInstanceName:

<cachingConfiguration defaultCacheManager="Cache Manager">
<cacheManagers>
<add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="Data Cache Storage" name="Cache Manager"/>
</cacheManagers>
<backingStores>
<add databaseInstanceName="CachingStaging" partitionName="CS" encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Data Cache Storage"/>
</backingStores>
</cachingConfiguration>