Closed andyhot closed 12 years ago
This is a very strange error message and it should not be possible to occur. The only active request is for IFilterProvider but it seems that it is already on the active bindings stack. I doubt that it is a problem of the MVC3 extension more likely it is a porblem in Ninject Core but I can't see any way such a behavior can occur yet.
Can you debug the application? If so can you please break at Ninject\Activation\Context.cs:148 and tell me the values of Binding and Request.ActiveBindings?
Fixed in 2.2.1.0
thx - will try it soon - was the fix in 49471e030e5ab8a59de1e8128c04d241f9b9e2fd ?
The commit fixing the issue is https://github.com/ninject/ninject.web.mvc/commit/ebc359a6aa5e13b32cd2bca509037c11a690309f
fix works great - thx
This exact error message still happens for us in very latest version of Ninject. We have 3 NuGet packages installed
Ninject (3.0.1.10) Ninject.Web.Common (3.0.0.7) Ninject.MVC3 (3.0.0.6)
I cant repeat that all the time, usually it happens after dozens of successful AJAX requests, and then this happens and entire application is broken. To fix it I have to restart app (recycly app pool or rebuild app in Visual Studio)
Right now this happening in MVC4 .NET 4.5 application, but we experienced the same error in MVC3 application as well
Any help in understanding why this is happening will be really appreciated. Thanks
Below exact stack trace.
Error activating IFilterProvider using binding from IFilterProvider to NinjectFilterProvider A cyclical dependency was detected between the constructors of two services.
Activation path: 1) Request for IFilterProvider
Suggestions: 1) Ensure that you have not declared a dependency for IFilterProvider on any implementations of the service. 2) Consider combining the services into a single one to remove the cycle. 3) Use property injection instead of constructor injection, and implement IInitializable if you need initialization logic to be run after property values have been injected. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Ninject.ActivationException: Error activating IFilterProvider using binding from IFilterProvider to NinjectFilterProvider A cyclical dependency was detected between the constructors of two services.
Activation path: 1) Request for IFilterProvider
Suggestions: 1) Ensure that you have not declared a dependency for IFilterProvider on any implementations of the service. 2) Consider combining the services into a single one to remove the cycle. 3) Use property injection instead of constructor injection, and implement IInitializable if you need initialization logic to be run after property values have been injected.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ActivationException: Error activating IFilterProvider using binding from IFilterProvider to NinjectFilterProvider A cyclical dependency was detected between the constructors of two services.
Activation path: 1) Request for IFilterProvider
Suggestions:
1) Ensure that you have not declared a dependency for IFilterProvider on any implementations of the service.
2) Consider combining the services into a single one to remove the cycle.
3) Use property injection instead of constructor injection, and implement IInitializable
if you need initialization logic to be run after property values have been injected.
]
Ninject.Activation.Context.Resolve() in c:\Projects\Ninject\ninject\src\Ninject\Activation\Context.cs:148
System.Linq.WhereSelectListIterator2.MoveNext() +245 System.Linq.<CastIterator>d__b1
1.MoveNext() +296
System.Linq.2.MoveNext() +578 System.Linq.Buffer
1..ctor(IEnumerable1 source) +520 System.Linq.<GetEnumerator>d__0.MoveNext() +252 System.Linq.Buffer
1..ctor(IEnumerable1 source) +520 System.Linq.<ReverseIterator>d__a0
1.MoveNext() +141
System.Web.Mvc.1..ctor(IEnumerable
1 source) +520
System.Linq.1.MoveNext() +141 System.Linq.WhereSelectEnumerableIterator
2.MoveNext() +165
System.Collections.Generic.List1..ctor(IEnumerable
1 collection) +536
System.Linq.Enumerable.ToList(IEnumerable1 source) +80 System.Web.Mvc.FilterInfo..ctor(IEnumerable
1 filters) +347
System.Web.Mvc.ControllerActionInvoker.GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +46
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +257
System.Web.Mvc.<>cDisplayClass1d.1.Begin(AsyncCallback callback, Object state, Int32 timeout) +146 System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate
1 endDelegate, Object tag, Int32 timeout) +166
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +543
System.Web.Mvc.Async.WrappedAsyncResult1.Begin(AsyncCallback callback, Object state, Int32 timeout) +146 System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate
1 endDelegate, Object tag, Int32 timeout) +166
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, Object tag) +27
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +409
System.Web.Mvc.<>cDisplayClass8.1.Begin(AsyncCallback callback, Object state, Int32 timeout) +146 System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate
1 endDelegate, Object tag, Int32 timeout) +166
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, Object tag) +27
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +364
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12551795
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Same
Can you confirm that you are not using any custom IDependencyResolver implementation but the one from Ninject.Web.MVC3?
I just confirmed that I was using a custom IDependencyResolver. Switching to the one from the Ninject.Web.MVC3 assembly fixed my problem. Thanks for making me check and and sorry for the red herring :-) love the product.
It hapened right now for me... It's a shame. I was using a custom implementation of IDependencyResolver and I have changed to Ninject.Web.Mvc.NinjectDependencyResolver. I'm testing with no errors. It seems to fixed. I have 4 applications working with the same dll. That error just happend on the fifth application.
thank you
I am also having this issue I am using following implementation to setup my implementation with interfaces in my mvc project.
namespace MoftakSolutions.WebUI.Infrastructure { public class NinjectDependencyResolver : IDependencyResolver { private IKernel kernel;
public NinjectDependencyResolver() {
kernel = new StandardKernel();
AddBindings();
}
public object GetService(Type serviceType) {
return kernel.TryGet(serviceType);
}
public IEnumerable<object> GetServices(Type serviceType) {
return kernel.GetAll(serviceType);
}
public IBindingToSyntax<T> Bind<T>() {
return kernel.Bind<T>();
}
public IKernel Kernel {
get { return kernel; }
}
private void AddBindings() {
// put additional bindings here
//kernel.Inject(Roles.Provider);
Bind<NewsletterSubscribersService>().To<NewsletterSubscribersService>().WithConstructorArgument("repo", new NewsletterSubscribersRepository());
Bind<JobsService>().To<JobsService>().WithConstructorArgument("repo", new JobsRepository());
Bind<NewsService>().To<NewsService>().WithConstructorArgument("repo", new NewsRepository());
// create the email settings object
}
}
This exact error message still happens for me in the last version of Ninject
A cyclical dependency was detected between the constructors of two services. Activation path: 1) Request for IFilterProvider
I keep getting this in a production server after a few hours of flawless execution. I don't see any other exceptions in the elmah logs and my current guess is that the server is reloading/restarting the app somehow and this leads to the exceptions. Of course, once those appear, the whole app is unusable.
I'm using Ninject 2.2.0.0 and Ninject.Web.Mvc 2.2.0.3 and extend NinjectHttpApplication in my Global.asax.cs (Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1; ASP.MVC 3)
Here's the full trace