Click here to Skip to main content
15,896,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Getting the following error:

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.

XML
[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) +435
   Ninject.Components.ComponentContainer.Get() +112
   Ninject.Web.Common.<>c__DisplayClass2.<DeactivateInstancesForCurrentHttpRequest>b__1(IKernel kernel) +72
   Ninject.GlobalKernelRegistration.MapKernels(Action`1 action) +231
   Ninject.Web.Common.OnePerRequestHttpModule.DeactivateInstancesForCurrentHttpRequest() +161
   Ninject.Web.Common.OnePerRequestHttpModule.<Init>b__0(Object o, EventArgs e) +34
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69


First load is ok, After returning to same url its crashing with this error above.


Calling ninjectmodules in my startup.auth
private static void RegisterServices(IKernel kernel)
{
    kernel.Load<NinjectModules>();
}



C#
public class NinjectModules : NinjectModule
{
    public override void Load()
    {
        this.Bind<ICombipacConfiguration>().To<CombipacConfigurationFactory>();
        this.Bind<ILogger>().ToMethod(context => new Log4NetWrapper(context.Request.Target.Member.ReflectedType));

        this.Bind<ICombipacApi>().ToProvider(this.Kernel.Get<CombipacApiFactory>());

        this.Bind<IUserStore<CombiPacUser>>().To<CombiPacUserStore>();
    }
}


I'm out of idees what this could be.

Tryed to add reference Ninject.extensions.inteception. no result.

Found out that it keeps creating a new kernel all request I send. Anyone have a idee to dispose this or clear the current kernel? Trying to find where it is creating the new kernel.

Also found this but its never coming inside this code.

C#
using (IKernel kernel = new StandardKernel())
{
    kernel.Load<NinjectModules>();
    IParameter[] items = new IParameter[] {
        new ConstructorArgument("userManager", context.GetUserManager<CombiPacUserManager>()),
        new ConstructorArgument("authenticationManager", context.Authentication) };
    return kernel.Get<CombiPacSignInManager>(items);
}


so the only kernel create request is the one NinjectWebCommon.
C#
private static IKernel CreateKernel()
{
    var kernel = new StandardKernel();
    try
    {
        kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
        kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();

        RegisterServices(kernel);
        return kernel;
    }
    catch
    {
        kernel.Dispose();
        throw;
    }
}
Posted
Updated 12-Oct-15 3:44am
v2
Comments
Sreekanth Mothukuru 12-Oct-15 9:58am    
My be you need to create a Bind(ing) in Ninject Load method for ICache.
Wessel Beulink 12-Oct-15 10:08am    
Do you mean for clearing my ICache?

1 solution

Problem solved on deleting all ninject versions and add a other github ninject.web.mvc 3 project which solved the issue of recreating a new kernel over and over again.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900