ninject/ninject.extensions.interception — Issue #4: Collection modified exception
Author: giulianob
Created: 2011-10-14 02:54:27+00:00
State: open

Hello,

Sometimes when starting my application I get the following error:

Collection was modified; enumeration operation may not execute.
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at Ninject.Extensions.Interception.Registry.AdviceRegistry.HasAdvice(IContext context) in ninject.extensions.interception\src\Ninject.Extensions.Interception\Registry\AdviceRegistry.cs:line 55

This is running Ninject 2.2

I am currently refactoring my application and I am using Ninject in some places as a service locator until I have fully modified everything to be properly injected so I am using Get() quite a bit. I have read before that Ninject's create kernel is not thread safe, however, I am sharing the same kernel. It is possible it's an issue with my app but the problem did not occur until I switched to use Ninject. It also doesn't always happen and when it does it's only right when the app is first loading.

Let me know if I can provide any details or if this is probably my issue then I will do some deeper investigation.