title: Why is Ninject Bind with Interception returning an interface proxy?
body: <p>I'm trying to understand how <code>Ninject.Extensions.Interception</code> 3.0.0.8 is building dynamic proxies for my classes. I've found that when I decorate my concrete classes with an attribute that inherits from <code>InterceptAttribute</code> or when I directly Intercept at binding time with <code>Intercept()</code> method then Ninject returns a Dynamic Proxy of the decorated class instead of the normal type.</p>
  
  <p>I have a <code>IPolicySearchPresenter</code> interface which I'm binding to <code>FlexPolicySearchPresenter</code> concrete type adding an Exception logger interceptor:</p>
  
  <pre><code>Bind&lt;IExceptionInterceptor&gt;().To&lt;ExceptionInterceptor&gt;();
  Bind&lt;IPolicySearchPresenter&gt;().To&lt;FlexPolicySearchPresenter&gt;().Intercept().With&lt;IExceptionInterceptor&gt;();
  </code></pre>
  
  <p>The problem is that when I inspect the returning type for that binding:</p>
  
  <pre><code>var proxy = Kernel.Get&lt;IPolicySearchPresenter&gt;();
  </code></pre>
  
  <p>I get an instance of <code>Castle.Proxies.IPolicySearchPresenterProxy</code> instead of <code>FlexPolicySearchPresenterProxy</code></p>
  
  <p>This is giving me problems with my FluorineFx remoting app. However, if I create my Castle Proxy manually: </p>
  
  <pre><code>ProxyGenerator generator = new ProxyGenerator();
      //My presenter type
      Type type = typeof(FlexPolicySearchPresenter);
      //My presenter interface
      var interfaceType = type.GetInterfaces().Single();
      //Get my Interceptor from container. Notice that i had to 
      //change my Interceptor to implement IInterceptor from Castle libs,
      // instead of Ninject IInterceptor
      var excepInt = Kernel.Get&lt;ExceptionInterceptor&gt;();
      //Manually get all my instances required by my presenter type Constructor
      //ideally passed through Constructor Injection
      var presenterSearchService = Kernel.Get&lt;IPolicySearchService&gt;();
      var userAuthService = Kernel.Get&lt;IUserAuthorizationService&gt;();
      //Create proxy, passing interceptor(s) and constructor arguments
      var proxy = generator.CreateClassProxy(type, new object[] { presenterSearchService, userAuthService },
              new IInterceptor[]
          {
              excepInt
          });
      //Ninject.Extensions.Interception.DynamicProxyModule
      // I'm using directive ToConstant(..), and not To(..)
      //Bind my interface to the new proxy
      Bind(interfaceType).ToConstant(proxy).InThreadScope();
  
  var proxy = Kernel.Get&lt;IPolicySearchPresenter&gt;();
  </code></pre>
  
  <p>The returning types come back as <code>Castle.Proxies.FlexPolicySearchPresenterProxy</code> which work perfectly with my remoting implementation.</p>
  
  <p>The question is, how can I get Ninject.Interception return me instances of <code>FlexPolicySearchPresenterProxy</code> instead of <code>IPolicySearchPresenterProxy</code>. 
  Notice that by doing the manual Castle way I am binding in a different way:</p>
  
  <pre><code>        Bind(interfaceType).ToConstant(proxy).InThreadScope();
  </code></pre>
  
  <p>Instead of the ninject way:</p>
  
  <pre><code>Bind&lt;IPolicySearchPresenter&gt;().To&lt;FlexPolicySearchPresenter&gt;().Intercept().With&lt;IExceptionInterceptor&gt;();
  </code></pre>
  
  <p>Do I need to change the way I'm doing the Binding in Ninject to get the right type?</p>