gpt4 book ai didi

与 OnePerRequestModule 相关的 Ninject 间歇性异常抛出

转载 作者:行者123 更新时间:2023-12-04 15:37:27 25 4
gpt4 key购买 nike

我刚刚将 Ninject 的现有实现从 1.5 升级到 2.0。我现在看到在短时间内发生许多请求时会抛出间歇性异常。

这是正在抛出的异常。

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)...



如果我删除 OnePerRequestModule,则不会抛出异常项目来自 httpModules在 web.config 中,但这会增加大量开销。

如果他们能提供帮助,我提前感谢任何人!

最佳答案

存在多线程问题。尝试使用在 https://github.com/ninject 中找到的 2.2 RC1 .请告诉我此版本是否仍然存在此问题,以确保我们在发布之前没有需要解决的其他问题。

关于与 OnePerRequestModule 相关的 Ninject 间歇性异常抛出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3841886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com