- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚从 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) in d:\BuildAgent-01\work\b68efe9aafe8875e\src\Ninject\KernelBase.cs:540
Ninject.<>c__DisplayClassa.b__6(IBinding binding) in d:\BuildAgent-01\work\b68efe9aafe8875e\src\Ninject\KernelBase.cs:375
System.Linq.<>c__DisplayClass12`3.b__11(TSource x) +20
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +151
System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +4178557
Ninject.Web.Mvc.NinjectDependencyResolver.GetService(Type serviceType) in c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectDependencyResolver.cs:56
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +51
[InvalidOperationException: An error occurred when trying to create a controller of type 'MyApp.Controllers.NewsController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +182
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +80
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +196
System.Web.Mvc.<>c__DisplayClass6.b__2() +49
System.Web.Mvc.<>c__DisplayClassb`1.b__a() +13
System.Web.Mvc.SecurityUtil.b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func`1 func) +124
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +98
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8862580
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
using System.Web.Mvc;
using Ninject.Modules;
[assembly: WebActivator.PreApplicationStartMethod(typeof(MyApp.AppStart_NinjectMVC3), "Start")]
namespace MyApp
{
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
using Ninject;
public static class AppStart_NinjectMVC3
{
public static void Start()
{
DynamicModuleUtility.RegisterModule(typeof(OnePerRequestModule));
DynamicModuleUtility.RegisterModule(typeof(NinjectHttpApplicationModule));
}
}
}
using MyApp.Data;
using NHibernate;
namespace MyApp
{
using System;
using System.Web;
using Ninject;
using Ninject.Web.Mvc;
public sealed class NinjectHttpApplicationModule : IHttpModule, IDisposable
{
#region Ninject Mvc3 extension bootstrapper (Do not touch this code)
private static readonly Bootstrapper bootstrapper = new Bootstrapper();
private static bool initialized;
private static bool kernelDisposed;
///
/// Initializes a module and prepares it to handle requests.
/// Do not change this method!
///
/// An that provides access to the methods, properties, and events common to all application objects within an ASP.NET application
public void Init(HttpApplication context)
{
lock (bootstrapper)
{
if (initialized)
{
return;
}
initialized = true;
bootstrapper.Initialize(CreateKernel);
}
}
///
/// Disposes the instance.
/// Do not change this method!
///
public void Dispose()
{
lock (bootstrapper)
{
if (kernelDisposed)
{
return;
}
kernelDisposed = true;
bootstrapper.ShutDown();
}
}
#khuvựccuối
///
/// Creates the kernel that will manage your application.
///
/// The created kernel.
private static IKernel CreateKernel()
{
var kernel = new StandardKernel();
RegisterServices(kernel);
return kernel;
}
///
/// Load your modules or register your services here!
///
/// The kernel.
private static void RegisterServices(IKernel kernel)
{
kernel.Bind().ToMethod(x => kernel.Get().CreateFactory().OpenSession()).InRequestScope();
kernel.Bind().ToMethod(x => kernel.Get().BeginTransaction()).InRequestScope();
kernel.Bind(typeof(IRepositoryBase<>)).To(typeof(RepositoryBase<>));
kernel.Bind().To();
}
}
}
RegisterServices()
1 Câu trả lời
在 2.2.1.0 中修复
Nhìn thấy http://www.planetgeek.ch/2011/03/01/ninject-2-2-1-0-and-ninject-mvc3-2-2-1-0-released/了解更多信息。
关于dependency-injection - 忍者 + "Error loading Ninject component ICache",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5134630/
这个问题已经有答案了: What does a 'Split' cache means. And how is it useful(if it is)? (1 个回答) 已关闭 2 年前。 有人可以解
我刚刚从 NuGet 安装了新的 Ninject.MVC3 并试图让它在我的 asp.net mvc 3 应用程序中工作,但是我在浏览我的网站时不时收到这个奇怪的错误: [InvalidOperati
我在 asp.net web api 项目中使用 ninject 并开始收到此间歇性 ninject 错误: " 加载 Ninject 组件 ICache 时出错 没有在内核的组件容器中注册此类组件。
我收到以下错误: System.InvalidOperationException: Error loading Ninject component ICache No such component
我遇到了以下错误: System.InvalidOperationException: Error loading Ninject component ICache No such component
我最近将 Ninject 和 Ninject.Web.Mvc 添加到现有的 ASP.NET MVC 4 Web 应用程序中。浏览网站时,我收到以下异常,似乎是随机的: [InvalidOperatio
Tôi là một lập trình viên xuất sắc, rất giỏi!