企业库CacheFactory.GetCacheManager抛出空参考 [英] Enterprise Library CacheFactory.GetCacheManager Throws Null Ref

查看:437
本文介绍了企业库CacheFactory.GetCacheManager抛出空参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将使用1.1版本的企业库缓存块的应用程序转换为2.0版本。我认为我真正有一个问题是,不同的EntLib片段的配置被分割在几个文件。显然,以前这是由 ConfigurationManagerSectionHandler 处理,但现在已经过时,有利于.NET 2.0中的内置配置机制。

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.

我很难找到一个很好的例子,如何做这个配置文件拆分,特别是在EntLib的上下文。有没有人处理这个?

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?

推荐答案

看起来像是配置。我在这里找到了一个正常的,一个文件的方法的一个很好的例子: http ://www.devx.com/dotnet/Article/31158/0/page/2

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

使用外部配置文件实际上是微不足道的out它的语法。例如:

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

在Web.config中:

In Web.config:

<cachingConfiguration configSource="cachingconfiguration.config" />

在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>

希望这有助于某人!

这篇关于企业库CacheFactory.GetCacheManager抛出空参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆