MemoryCache.Default抛出System.Configuration.ConfigurationException [英] MemoryCache.Default throws System.Configuration.ConfigurationException

查看:60
本文介绍了MemoryCache.Default抛出System.Configuration.ConfigurationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义角色提供程序,我在其中添加了一个简单的缓存。当MVC应用程序使用提供程序时,它工作正常。但是我正在使用一个测试应用程序,该应用程序使用角色提供程序对IsUserInRole方法进行并行和异步调用。

I have a custom Role Provider in which I'm adding a simple cache. It works fine when the provider is used by an MVC app. However I'm working on a test application which uses the Role Provider to make parallel and asynchronous calls to the IsUserInRole method.

当执行命中行ObjectCache cache = MemoryCache.Default;它会抛出一个带有上述堆栈的System.Configuration.ConfigurationException。 我检查过,如果我从代码中删除缓存,一切都像以前一样使用我的MVC项目
和我的其他单元测试项目。

When the execution hits the line ObjectCache cache = MemoryCache.Default; it throws a System.Configuration.ConfigurationException with the above stack.  I checked and if I remove the cache from the code everything works as before with my MVC project and my other Unit Test project.

BringRoles,它出现在堆栈中,  调用Active Directory,因此被IsUserInRole调用。

BringRoles, which appears in the stack, does the calls to the Active Directory, so it's called by IsUserInRole.

   àSystem.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)

   àSystem.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)

   àSystem.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)

   àSystem.Runtime.Caching.MemoryCacheStatistics.InitializeConfiguration(NameValueCollection config)

   àSystem.Runtime.Caching.MemoryCacheStatistics..ctor(MemoryCache memoryCache,NameValueCollection config)

   àSystem.Runtime.Caching.MemoryCache.InitDisposableMembers(NameValueCollection config)

   àSystem.Runtime.Caching.MemoryCache.Init(NameValueCollection config)

   àSystem.Runtime.Caching.MemoryCache.get_Default()

   àRolesProvider.AdMappedRoleProvider.BringRoles(String userName)dans D:\ Source \ ADMappedRoleProvider.cs:ligne 382

   à System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
   à System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
   à System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
   à System.Runtime.Caching.MemoryCacheStatistics.InitializeConfiguration(NameValueCollection config)
   à System.Runtime.Caching.MemoryCacheStatistics..ctor(MemoryCache memoryCache, NameValueCollection config)
   à System.Runtime.Caching.MemoryCache.InitDisposableMembers(NameValueCollection config)
   à System.Runtime.Caching.MemoryCache.Init(NameValueCollection config)
   à System.Runtime.Caching.MemoryCache.get_Default()
   à RolesProvider.AdMappedRoleProvider.BringRoles(String userName) dans D:\Source\ADMappedRoleProvider.cs:ligne 382

我怀疑在我的App.config中是否存在某些内容新的测试应用程序,但无法找到它可能是什么

I suspect something that is or is not in the App.config of my new test application but can't find what it could be

Daniel Siconnelli既没有好也没有邪恶...只有mogwais和gremlins

Daniel Siconnelli There is neither good nor evil... only mogwais and gremlins

推荐答案

你好,

 如果你能提供更多您的应用的详细信息和实际代码会有所帮助。

 If you could provide more details and actual code of your app would be helpful.

但是,根据您的说明,有一篇旧文章可能会有所帮助;

However, based on your description, there is an old article that may help or not;

  MemoryCache

 从我读到的内容,本文描述了使用包装器的实现

 From what I read, the article describes the implementation of a wrapper for use

使用ASP.NET。

 希望这会有所帮助:)

 Hope this helps :)


这篇关于MemoryCache.Default抛出System.Configuration.ConfigurationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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