Enterprise Library CacheFactory.GetCacheManager Throws Null Ref

一世执手 提交于 2020-01-24 04:26:05

问题


I'm trying to convert an application using the 1.1 version of the Enterprise Library Caching block over to the 2.0 version. I think where I'm really having a problem is that the configuration for the different EntLib pieces was split out over several files. Apparently, this used to be handled by the ConfigurationManagerSectionHandler, but is now obsolete in favor of the built-in configuration mechanisms in .NET 2.0.

I'm having a hard time finding a good example of how to do this configuration file splitting, especially in the context of EntLib. Has anyone else dealt with this?


回答1:


Looks like it was the configuration. I found a good example of the normal, one-file approach here: http://www.devx.com/dotnet/Article/31158/0/page/2

Using an external config file is actually trivial once you figure out the syntax for it. Ex.:

In Web.config:

<cachingConfiguration configSource="cachingconfiguration.config" />

In cachingconfiguration.config:

<?xml version="1.0" encoding="utf-8"?>
<cachingConfiguration defaultCacheManager="Default Cache Manager">
    <backingStores>
        <add name="inMemory" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching" />
    </backingStores>
    <cacheManagers>
        <add name="Default Cache Manager" expirationPollFrequencyInSeconds = "60" maximumElementsInCacheBeforeScavenging ="50" numberToRemoveWhenScavenging="10" backingStoreName="inMemory" />
    </cacheManagers>
</cachingConfiguration>

Hopefully this helps somebody!



来源:https://stackoverflow.com/questions/9136/enterprise-library-cachefactory-getcachemanager-throws-null-ref

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!