I am trying to implement enterprise library caching and logging.
I have the latest version (6.0.1304.0) of EnterpriseLibrary.Logging and EnterpriseLibrary.Common
I have the latest version (5.0.505.0) of EnterpriseLibrary.Caching
I am getting the below error when I create cache managerCacheManager cacheManager = (CacheManager)CacheFactory.GetCacheManager();
System.TypeLoadException HResult=0x80131522 Message=Could not load type 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer' from assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Source=Microsoft.Practices.EnterpriseLibrary.Caching
Below is my web.config
<configSections>
<section name="cachingConfiguration"
type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,
Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<cachingConfiguration defaultCacheManager="Default Cache Manager">
<cacheManagers>
<add name="Default Cache Manager" expirationPollFrequencyInSeconds="60"
maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10"
backingStoreName="inMemory" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager,Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</cacheManagers>
<backingStores>
<add name="inMemory" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</backingStores>
</cachingConfiguration>

According Microsoft Learn documentation (TypeLoadException Class), this type of exception occurs when the Assembly cannot be found by Common Languange Runtime; like documentation, please, check if the Solution library (DLL) reference point to a different version of Microsoft.Practices.EnterpriseLibrary based on the Web.Config, this maybe the root-cause.