我在谷歌搜索但我没有找到解决方案来解决该错误。我正在尝试创建缓存管理器的实例,但获得异常。我使用的是Enterprise library 5.0。我找不到我的问题。我完全陷入困境。任何提示都很明显。
ICacheManager cachManager = EnterpriseLibraryContainer.Current.GetInstance<ICacheManager>();
或
var cm = CacheFactory.GetCacheManager("Cache Manager");
配置信息
<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="Cache Manager">
<cacheManagers>
<add name="Cache Manager" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="10000" numberToRemoveWhenScavenging="10" backingStoreName="NullBackingStore" />
</cacheManagers>
<backingStores>
<add type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="NullBackingStore" />
</backingStores>
</cachingConfiguration>
答案 0 :(得分:0)
当我从v.5.0.414.0升级到5.0.505.0版时,我遇到了同样的问题。在我的情况下,我必须确保在调用CacheFactory.GetCacheManager(..)
之前执行以下操作并且它再次正常工作。
// first call this
Container.AddNewExtension<EnterpriseLibraryCoreExtension>();
// and then
ICacheManager cacheManager = CacheFactory.GetCacheManager("Cache Manager");