我在asp.net web api项目中使用ninject并且已经开始接收这个间歇性的ninject错误:
" 加载Ninject组件时出错ICache没有在内核的组件容器中注册这样的组件. "
我正在使用:
他们都被带入了我的项目,NuGet我在IocConfig.RegisterIoc中加载我的模块,并没有做任何其他更改或调整.
它可能是不相关的,但问题开始发生在我开始将IKernel注入我的一个构造函数的同时.关于"特殊解析器",我没有为此设置约束.
我在这里已经阅读了许多类似的问题:
Ninject +"加载Ninject组件ICache时出错"
MVC3项目中的Ninject和ChildKernel:"加载Ninject组件ICache时出错"
随机发生的Ninject异常:"加载Ninject组件ICache时出错"
虽然在每种情况下OP都有与我相同的错误,但解决方案并不合适 - 我没有创建子内核,而且我没有使用ninject的错误版本.
我刚刚从NuGet安装了新的Ninject.MVC3并试图让它在我的asp.net mvc 3应用程序中运行,但是我现在得到这个奇怪的错误,然后在浏览我的网站时:
[InvalidOperationException: Error loading Ninject component ICache
No such component has been registered in the kernel's component container.
Suggestions:
1) If you have created a custom subclass for KernelBase, ensure that you have properly
implemented the AddComponents() method.
2) Ensure that you have not removed the component from the container via a call to RemoveAll().
3) Ensure you have not accidentally created more than one kernel.
]
Ninject.Components.ComponentContainer.Get(Type component) in d:\BuildAgent-01\work\b68efe9aafe8875e\src\Ninject\Components\ComponentContainer.cs:146
Ninject.Components.ComponentContainer.Get() in d:\BuildAgent-01\work\b68efe9aafe8875e\src\Ninject\Components\ComponentContainer.cs:102
Ninject.KernelBase.CreateContext(IRequest request, IBinding binding) …Run Code Online (Sandbox Code Playgroud)