Error loading Ninject ICache component

I am using ninject in an asp.net web api project and started getting this intermittent ninject error:

" Error loading Ninject ICache component. This component has not been registered in the kernel component container. "

I use:

  • Ninject 3.0.1.10
  • Ninject.MVC3 3.0.0.6
  • Ninject.Web.Common 3.0.0.7

All of them are included in my project with NuGet. I load my modules in IocConfig.RegisterIoc and have not made any other changes or settings.

It may be unrelated, but the problem arose around the same time when I started injecting IKernel into one of my constructors. I did not set the binding for this after reading about the “special recognizer”.

I read a number of similar questions here:

Ninject + "Error loading Ninject ICache component"

Ninject and ChildKernel in MVC3 project: "Error loading component" Component Initiative ", etc.

Ninject accidental exception: "Error loading Ninject ICache component"

Although in each of these cases the OP has the same error as me, the solution does not fit - I do not create child kernels, and I do not use the listening version of ninject.

+8
asp.net-web-api ninject
source share
1 answer

Found a solution and thought I wanted to share.

The problem was that I used Ninject.MVC3, which seems to be the wrong package for the Web API.

Instead, I need to use the Ninject.Web.WebApi-RC package, as described in this post:

http://www.eyecatch.no/blog/2012/06/using-ninject-with-webapi-rc/

The steps I took to fix it

  • Deleted Ninject.MVC3 and Ninject.Web.Common
  • delete all ninject files from the App_Start folder.
  • install Ninject.Web.Common and Ninject.Web.WebApi-RC from nuget
  • Download my modules in NinjectWebCommon.RegisterServices ()
+5
source share

All Articles