Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems when Upgrading from 3.2.1 to 3.2.2 - ICache Error #18

Open
squadwuschel opened this issue Jun 27, 2014 · 3 comments
Open

Problems when Upgrading from 3.2.1 to 3.2.2 - ICache Error #18

squadwuschel opened this issue Jun 27, 2014 · 3 comments

Comments

@squadwuschel
Copy link

Hi,

I have a Project, where I am using the following Ninject Components:
with this Confoguration everything works fine

<package id="Ninject" version="3.2.2.0" targetFramework="net40" />
<package id="Ninject.MVC4" version="3.2.1.0" targetFramework="net40" />
<package id="Ninject.Web.Common" version="3.2.1.0" targetFramework="net40" />
<package id="Ninject.Web.Common.WebHost" version="3.2.1.0" targetFramework="net40" />

When I update the Ninject.Web.Common to:

<package id="Ninject.Web.Common" version="3.2.2.0" targetFramework="net40" />

I get the following Error, when I am calling the Website:

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.
    Beschreibung: Unbehandelte Ausnahme beim Ausführen der aktuellen Webanforderung. Überprüfen Sie die Stapelüberwachung, um weitere Informationen über diesen Fehler anzuzeigen und festzustellen, wo der Fehler im Code verursacht wurde.

Ausnahmedetails: System.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.

Quellfehler:

Beim Ausführen der aktuellen Webanforderung wurde einen unbehandelte Ausnahme generiert. Informationen über den Ursprung und die Position der Ausnahme können mit der Ausnahmestapelüberwachung angezeigt werden.

Stapelüberwachung:

[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) +425
    Ninject.Components.ComponentContainer.Get() +50
    Ninject.Web.Common.<>c__DisplayClass2.b__1(IKernel kernel) +58
    Ninject.GlobalKernelRegistration.MapKernels(Action`1 action) +172
    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

My NinjectWebCommon.cs looks like:

      /// <summary>
      /// Load your modules or register your services here!
      /// </summary>
      /// <param name="kernel">The kernel.</param>
      private static void RegisterServices(IKernel kernel)
       {
       //Mvc Skeleton Bindings laden
        kernel.Load(new Internal.MvcSkeleton.Gui.Mvc.NinjectBindings());

        //Home Controller Bindings
        kernel.Bind<IRechnungsmonitorDashboardViewModelBuilder>().To<RechnungsmonitorDashboardViewModelBuilder>().InRequestScope();
        kernel.Bind<IOverviewModelBuilder>().To<OverviewModelBuilder>().InRequestScope();
        kernel.Bind<ISearchModelBuilder>().To<SearchModelBuilder>().InRequestScope();
        kernel.Bind<IMantisDashboardViewModelBuilder>().To<MantisDashboardViewModelBuilder>().InRequestScope();
       ....

If you need more Informations please tell me

thx
squadwuschel

@scott-xu
Copy link
Member

Would you mind send a sample demo to me?

@v-braun
Copy link

v-braun commented Aug 3, 2018

I have the same issue, is there a solution for that?

@v-braun
Copy link

v-braun commented Aug 4, 2018

Unfortunately, I cannot post example code for my issue here because of policies with my customer.
But I figured out that the error appears when I use a second Kernel instance that is disposed.

Is it possible to use multiple Kerne instances with this Framework?

Let me describe my context a littlebit:

I multiple Plugins for dedicated Tasks in my App.
A Plugin can be hosted in an API, an Azure WebJob or in other Environments like UnitTests, ConsoleApps, etc.

Every Plugin has it's own Kernel and own DI registrations.
In that specific case is a Plugin hosted in an API.
It is created and disposed on a specific WebApi Action call.
When the Request is done (the Action method is leaved) the Plugin (and his Kernel) will be disposed.
When that happened I will get everytime that error.
Calls to other actions will then also fail (also to complete empty actions).

I looked into your code and find that line here.

And if I check the base class GlobalKernelRegistration MapKernels method it looks like Kernels are stored as WeakReferences by Ninject.
At the end of this method kernels that are no longer alive (!reference.IsAlive) will be removed.
But such kernels will be passed to the action callback.
Because of that Exception the dead kernel could not be removed and that error will happen on next request also.
Maybe it would help simple hide that Exception on your code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants