I am using ninject in an asp.net web api project and have started receiving this intermittent ninject error:
"Error loading Ninject component ICache No such component has been registered in the kernel's component container."
I'm using:
They are all brought into my project with NuGet I load my Modules in IocConfig.RegisterIoc and have made no other changes or tweaks.
It may be unrelated but the problem started occurring at around the same time as I started injecting IKernel into one of my constructors. I didn't set up a binding for this having read about the "special resolver".
I have read through a number of similar questions on here:
Ninject + "Error loading Ninject component ICache"
Ninject and ChildKernel in MVC3 project: "Error loading Ninject component ICache"
Randomly-Occurring Ninject Exception: "Error loading Ninject component ICache"
Although in each of these cases the OP has the same error as me the solution is not appropriate - I am not creating child kernels and I'm not using the bugged version of ninject.
Found the solution and thought I would share.
The problem was that I was Using Ninject.MVC3 which seems to be wrong package for Web-API.
Instead I need to use Ninject.Web.WebApi-RC package as described by this post:
http://www.eyecatch.no/blog/2012/06/using-ninject-with-webapi-rc/
Steps I followed for a fix are
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With