1
votes

I am using Ninject 3.2.0.0 with Ninject.Extension.Factory 3.2.0.0 in a webforms application.

I am getting error reports of the following...

Error loading Ninject component IAdviceRegistry 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.

at Ninject.Components.ComponentContainer.Get(Type component) in c:\Projects\Ninject\ninject\src\Ninject\Components\ComponentContainer.cs:line 162 at Ninject.Components.ComponentContainer.GetT in c:\Projects\Ninject\ninject\src\Ninject\Components\ComponentContainer.cs:line 116 at Ninject.Extensions.Interception.Activation.Strategies.ProxyActivationStrategy.ShouldProxy(IContext context) in c:\Projects\Ninject\ninject.extensions.interception\src\Ninject.Extensions.Interception\Activation\Strategies\ProxyActivationStrategy.cs:line 66 at Ninject.Extensions.Interception.Activation.Strategies.ProxyActivationStrategy.Deactivate(IContext context, InstanceReference reference) in c:\Projects\Ninject\ninject.extensions.interception\src\Ninject.Extensions.Interception\Activation\Strategies\ProxyActivationStrategy.cs:line 51 at Ninject.Activation.Pipeline.<>c__DisplayClass6.b__4(IActivationStrategy s) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Pipeline.cs:line 72 at Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map[T](IEnumerable1 series, Action1 action) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForIEnumerableOfT.cs:line 31 at Ninject.Activation.Pipeline.Deactivate(IContext context, InstanceReference reference) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Pipeline.cs:line 74 at Ninject.Activation.Caching.Cache.Forget(CacheEntry entry) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Caching\Cache.cs:line 254 at Ninject.Activation.Caching.Cache.Forget(IEnumerable`1 cacheEntries) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Caching\Cache.cs:line 240 at Ninject.Activation.Caching.Cache.Clear(Object scope) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Caching\Cache.cs:line 198 at Ninject.Activation.Caching.Cache.<>c__DisplayClass3.b__1(Object o, EventArgs e) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Caching\Cache.cs:line 94 at Ninject.Activation.Blocks.ActivationBlock.Dispose(Boolean disposing) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Blocks\ActivationBlock.cs:line 59 at Ninject.Infrastructure.Disposal.DisposableObject.Dispose() in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Disposal\DisposableObject.cs:line 33 at Brightspot.WebApi.Ioc.NinjectDependencyScope.Dispose() at System.Net.Http.HttpRequestMessageExtensions.DisposeRequestResources(HttpRequestMessage request)

2

2 Answers

0
votes

Make sure the extensions

  • ninject.extensions.interception
  • Ninject.Extensions.Interception.DynamicProxy

or the extensions

  • ninject.extensions.interception
  • Ninject.Extensions.Interception.Linfu

are present.

EDIT:

The registration of the IAdviceRegistry is part of the InterceptionModule of the ninject.extensions.interception extension.

So the extension is not loaded properly. This is either because the extension dll was not properly copied to the output path / deployment path or (most likely issue) or you have configured the kernel to not autoload extensions / not do it correctly.

If you're using the StandardKernel without modifying any settings you should be good. However changing INinjectSettings.LoadExtensions = false or changing INinjectSettings.ExtensionSearchPatterns can break things.

0
votes

Finally I found that issue.If we use factory pattern load the functional module in ninject. The functional module not loaded properly while using factory pattern. So you need to load the functional module in ninject.. And access the factory class using standard kernel...

this.Kernel.Load(new[] { new FuncModule() });
StandardKernel.Get<IApproveContextFactory>()