Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NinjectHttpApplication doesn't work after porting to web api 2

I have ported my Web Api application to Web Api 2 and installed ninject web api pacckage. But now I am getting an error:

Error activating ModelValidatorProvider using binding from ModelValidatorProvider to NinjectDefaultModelValidatorProvider

A cyclical dependency was detected between the constructors of two services.
like image 878
Alex Lapa Avatar asked May 06 '14 20:05

Alex Lapa


1 Answers

I had this same issue. I got it when I added Ninject.Web.WebApi as a Nuget package.

To resolve the issue, I had to remove a workaround that I had previously implemented.

In the previous workaround, I had set the dependency resolver in NinjectWebCommon to a custom class that implemented IDependencyResolver.

In short, if you have a line similar to GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel); in NinjectWebCommon's CreateKernel(), remove it.

like image 200
A Dumb Rhine King Avatar answered Sep 20 '22 17:09

A Dumb Rhine King