Ninject 抛出与 OnePerRequestModule 相关的间歇性异常
我刚刚将 Ninject 的现有实现从 1.5 升级到 2.0。我现在看到当短时间内发生许多请求时会抛出间歇性异常。
这是抛出的异常。
类型: System.ArgumentException
消息:已添加具有相同密钥的项目。
来源: Ninject
堆栈跟踪:位于 System.ThrowHelper.ThrowArgumentException(ExceptionResource 资源)
在 System.Collections.Generic.Dictionary`2.Insert(TKey 键,TValue 值,布尔添加)
在 System.Collections.Generic.Dictionary`2.Add(TKey 键,TValue 值)
在 Ninject.Components.ComponentContainer.CreateNewInstance(类型组件,类型实现)
在 Ninject.Components.ComponentContainer.ResolveInstance(类型组件,类型实现)
在 Ninject.Components.ComponentContainer.Get(类型组件)
在 Ninject.Components.ComponentContainer.b__6(ParameterInfo 参数)
在 System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
在 System.Linq.Buffer`1..ctor(IEnumerable`1 源)
在 System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 源)
在 Ninject.Components.ComponentContainer.CreateNewInstance(类型组件,类型实现)
在 Ninject.Components.ComponentContainer.ResolveInstance(类型组件,类型实现)
在 Ninject.Components.ComponentContainer.Get(类型组件)
在 Ninject.Components.ComponentContainer.GetT
在Ninject.KernelBase.CreateContext(IRequest请求,IBinding绑定)
at Ninject.KernelBase.<>c__DisplayClassa.b__6(IBinding 绑定)
在 System.Linq.Enumerable。<>c__DisplayClass12`3。b__11(TSource x)
在 System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
在 System.Linq.Enumerable.d__aa`1.MoveNext()
在 System.Linq.Enumerable.Single[TSource](IEnumerable`1 源)
在 Ninject.ResolutionExtensions.Get[T](IResolutionRoot 根,IParameter[] 参数)
在 NameOfConsumingSite.Application_BeginRequest(Object sender, EventArgs e)...
如果我从 httpModules
中删除 OnePerRequestModule
项,则不会引发异常web.config,但这会增加大量的开销。
如果有人可以提供帮助,我提前感谢他们!
I just upgraded an existing implementation of Ninject from 1.5 to 2.0. I'm now seeing an intermittent exception getting thrown when many requests are happening in a short period of time.
Here's the exception that is being thrown.
Type: System.ArgumentException
Message: An item with the same key has already been added.
Source: Ninject
Stack Trace: at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Ninject.Components.ComponentContainer.CreateNewInstance(Type component, Type implementation)
at Ninject.Components.ComponentContainer.ResolveInstance(Type component, Type implementation)
at Ninject.Components.ComponentContainer.Get(Type component)
at Ninject.Components.ComponentContainer.<CreateNewInstance>b__6(ParameterInfo parameter)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Ninject.Components.ComponentContainer.CreateNewInstance(Type component, Type implementation)
at Ninject.Components.ComponentContainer.ResolveInstance(Type component, Type implementation)
at Ninject.Components.ComponentContainer.Get(Type component)
at Ninject.Components.ComponentContainer.GetT
at Ninject.KernelBase.CreateContext(IRequest request, IBinding binding)
at Ninject.KernelBase.<>c__DisplayClassa.<Resolve>b__6(IBinding binding)
at System.Linq.Enumerable.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource x)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.<CastIterator>d__aa`1.MoveNext()
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at Ninject.ResolutionExtensions.Get[T](IResolutionRoot root, IParameter[] parameters)
at NameOfConsumingSite.Application_BeginRequest(Object sender, EventArgs e)...
The exception does not get thrown if I remove the OnePerRequestModule
item from httpModules
in web.config, but that is adding a ton of overhead.
I thank anyone in advance if they can help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
存在多线程问题。尝试使用 https://github.com/ninject 中找到的 2.2 RC1。请告诉我此版本是否仍然出现此问题,以确保我们在发布之前没有需要修复的进一步问题。
There was a multithreading problem. Try to use the 2.2 RC1 found at https://github.com/ninject . Please tell me if this problem still occurs with this version to make sure we have no further issue we have to fix before release.