ASP.NET MVC Error loading Ninject component ICache

倖福魔咒の 提交于 2019-12-11 04:09:19

问题


I've been getting the following error:

System.InvalidOperationException: Error loading Ninject component ICache
No such component has been registered in the kernel's component container.

Using the following NuGet packages:

  • Ninject 3.0.1.10
  • Ninject.MVC3 3.0.0.6
  • Ninject.Web.Common 3.0.0.7
  • ASP.NET MVC 4.0.30506.0

The Binding are setup using WebActivator and the Ninject Bootstrapper (default setup).

It appears this error was once an issue before Ninject 2.2.1.0 and Ninject.MVC3 2.2.1.0 were released and this article is similar but I'm not using Web.Api Error loading Ninject component ICache.

It might be worth noting that I have two Kernels. The main kernel is created at application start-up and is disposed on shutdown. The second kernel us used during start-up but is disposed almost immediately as it's not needed again. So would this possibly cause the issue?


回答1:


In my case this was because I was following someone's System.Web.Http.Dependencies.IDependencyResolver Ninject wrapper where the Dispose() method would call dispose on the kernel.




回答2:


It turns out the issue was due to the fact that there were two Kernels. They must have been conflicting somehow, I didn't determine the cause and opted to remove the second Kernel.



来源:https://stackoverflow.com/questions/21325637/asp-net-mvc-error-loading-ninject-component-icache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!