问题
I am using Ninject 2.2.1.0 with Ninject.Web 2.2.0.0 in a webforms application.
I am getting daily error reports of the following...
System.InvalidOperationException: Collection was modified; enumeration
operation may not execute. at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at System.Collections.Generic.List
1.Enumerator.MoveNextRare() at System.Collections.Generic.List
1.Enumerator.MoveNext() at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext() at Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map[T](IEnumerable
1 series, Action`1 action) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForIEnumerableOfT.cs:line 22 at Ninject.OnePerRequestModule.DeactivateInstancesForCurrentHttpRequest() in c:\Projects\Ninject\ninject\src\Ninject\OnePerRequestModule.cs:line 63 at Ninject.OnePerRequestModule.b__0(Object o, EventArgs e) in c:\Projects\Ninject\ninject\src\Ninject\OnePerRequestModule.cs:line 36 at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Seems to be occuring at peak times. Is there a stable release with this patched yet?
回答1:
Creation of kernel instances is not thread safe at the moment. This will probably be changed with 2.4
来源:https://stackoverflow.com/questions/6028564/ninject-runtime-exception-occuring-frequently-system-invalidoperationexception