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.
[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>();
}
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.
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.
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;
}
}