1

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)

parthicool05
  • 255
  • 1
  • 10

2 Answers2

0

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.

BatteryBackupUnit
  • 12,934
  • 1
  • 42
  • 68
  • I checked it out. But still the issue came – parthicool05 Jul 03 '14 at 05:26
  • What did you exactly check out? Is the extension dll copied to the same path as the exe is executed from? Is this the same as the execution path (like "start in" of a shortcut)? is extension loading enabled? – BatteryBackupUnit Jul 03 '14 at 05:39
  • Could you try to do `IKernel.Load()`? – BatteryBackupUnit Jul 03 '14 at 05:52
  • So you are probably injecting a factory before loading the InterceptionModule. You or some code is... btw. You need to be way more specific about what you do and so on if you want to really get some help. – BatteryBackupUnit Jul 03 '14 at 07:16
  • StandardKernel kernel = new StandardKernel(new NinjectSettings() { LoadExtensions = false, }); this.Kernel.Load(new[] { new FuncModule() }); this.Kernel.Bind().ToSelf(); this.Kernel.Bind(typeof(IRepository<>)).To(typeof(EFRepository<>)); this.Kernel.Bind(typeof(IService<>)).To(typeof(Service<>)); this.Kernel.Bind().ToFactory(); – parthicool05 Jul 03 '14 at 07:36
  • uhm there's a lot of errors in that. First, **don't** set `LoadExtensions = false`. Second, **don`t** `.Bind()`. That's totally useless. You *may* try `.Load – BatteryBackupUnit Jul 03 '14 at 07:45
  • If I load this kernel.Load(); I get the this issue Error 2 'Ninject.Extensions.Interception.InterceptionModule' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'TModule' in the generic type or method 'Ninject.ModuleLoadExtensions.Load(Ninject.IKernel) – parthicool05 Jul 03 '14 at 09:11
  • **Remove** any code pertaining `InterceptionModule`. **Change** `LoadExtensions = false` to `LoadExtensions = true`. – BatteryBackupUnit Jul 03 '14 at 09:37
0

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>()
parthicool05
  • 255
  • 1
  • 10