【发布时间】:2014-07-22 03:32:03
【问题描述】:
使用 .net 3.5 和 Enterprise library 5.0。
根据我的研究,我在这里发现了一个类似的问题: Activation error occured while trying to get instance of type ICacheManager, key "Cache Manager" *** 这个解决方案没有解决我的问题。
我似乎无法弄清楚,我的配置应该设置正确,但不断收到异常?谁有类似的问题?
我建议在调用缓存管理器时添加缓存管理器和引用:
using Microsoft.Practices.EnterpriseLibrary.Caching;
using Microsoft.Practices.EnterpriseLibrary.Caching.Expirations;
.....
....
ICacheManager cm = CacheFactory.GetCacheManager("TrackingCacheManager");
App.config:
<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>
<cachingConfiguration defaultCacheManager="TrackingCacheManager">
<cacheManagers>
<add name="TrackingCacheManager" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
expirationPollFrequencyInSeconds="120" maximumElementsInCacheBeforeScavenging="1000"
numberToRemoveWhenScavenging="10" backingStoreName="NullBackingStore" />
</cacheManagers>
<backingStores>
<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>
<dataConfiguration defaultDatabase="ConnectionString" />
<connectionStrings>
<add name="ConnectionString" connectionString="server=AFS7BCBRNGQ5O0\DEVELOPMENT;database=EITC_RTS;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
我的参考资料:
【问题讨论】:
-
确保在 App.config 中定义了完整的配置引用跟踪侦听器。有关详细信息,请查看 - stackoverflow.com/questions/7813925/…
-
日志相关的例子,我需要一个数据访问块的监听器吗?
-
您是否尝试过从配置中删除
PublicKeyToken?您可能拥有具有不同令牌的 DLL,当它们不匹配时,您会遇到异常。 -
在调用GetCacheManager()时不指定Cache名称是否会得到同样的结果?
标签: c# .net caching enterprise-library