Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't get Ninject.Extensions.Interception working
    primarykey
    data
    text
    <p>I've been trying for ages to figure this our. when i try to bind my class with an interceptor i'm getting the following exception on the line </p> <pre><code>Kernel.Bind&lt;MyClass&gt;().ToSelf().Intercept().With&lt;ILoggerAspect&gt;(); </code></pre> <p><strong>Error loading Ninject component IAdviceFactory. No such component has been registered in the kernel's component container</strong></p> <p>I've tried with and without LoadExtensions, With about with using a Module to set up my bindings and my last attempt looks like this</p> <pre><code>internal class AppConfiguration { internal AppConfiguration( ) { var settings = new NinjectSettings() { LoadExtensions = false }; Kernel = new StandardKernel(settings); Load(); } internal StandardKernel Kernel { get; set; } public static AppConfiguration Instance { get { return _instance ?? (_instance = new AppConfiguration()); } } private static AppConfiguration _instance; private void Load() { Kernel.Bind&lt;ILoggerAspect&gt;().To&lt;Log4NetAspect&gt;().InSingletonScope(); Kernel.Bind&lt;MyClass&gt;().ToSelf().Intercept().With&lt;ILoggerAspect&gt;(); } internal static StandardKernel Resolver() { return Instance.Kernel; } } </code></pre> <p>My Logger Attribute looks like this </p> <pre><code>public class LogAttribute : InterceptAttribute { public override IInterceptor CreateInterceptor(IProxyRequest request) { return request.Context.Kernel.Get&lt;ILoggerAspect&gt;(); } } </code></pre> <p>And my interceptor like this</p> <pre><code> public class Log4NetAspect : SimpleInterceptor, ILoggerAspect { protected override void BeforeInvoke(IInvocation invocation) { Debug.WriteLine("Running " + invocation.ReturnValue); base.BeforeInvoke(invocation); } public new void Intercept(IInvocation invocation) { try { base.Intercept(invocation); } catch (Exception e) { Debug.WriteLine("Exception: " + e.Message); } } protected override void AfterInvoke(IInvocation invocation) { Debug.WriteLine("After Method"); base.AfterInvoke(invocation); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload