title: Castle WCF Integration Facility
body: <p>I’m trying to use Castle WCF integration facility in my project. I followed instructions from the castle official site <a href="http://docs.castleproject.org/Windsor.WCF-Facility-Registration.ashx" rel="nofollow">http://docs.castleproject.org/Windsor.WCF-Facility-Registration.ashx</a> 
  But I couldn't make it work. Here's my code and configuration.</p>
  
  <pre><code>protected void Application_Start(object sender, EventArgs e)
  {
      BuildContainer();
  }
  
  private void BuildContainer()
      {
          Container = new WindsorContainer();
  
  
          //1st
          Container.Kernel.AddFacility&lt;WcfFacility&gt;();
          Container.Kernel.Register(Component.For&lt;IProductService&gt;()
                                             .ImplementedBy&lt;ProductService&gt;()
                                             .Named("ProductService"));
  
          //2nd
          Container.AddFacility&lt;WcfFacility&gt;()
              .Install(Castle.Windsor.Installer.Configuration.FromXmlFile("Castle.config"));
  
  
  
          //3rd
          Container.Register(
                     Component.For&lt;IProductService&gt;()
                         .ImplementedBy&lt;ProductService&gt;()
                         .LifeStyle.PerWcfOperation()
                         .AsWcfService(new DefaultServiceModel()
                             .AddEndpoints(WcfEndpoint.BoundTo(new WSHttpBinding(SecurityMode.None)
                             {
                                 MaxReceivedMessageSize = Int32.MaxValue,
                                 MaxBufferPoolSize = Int32.MaxValue,
                                 ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas
                                 {
                                     MaxStringContentLength = Int32.MaxValue
                                 }
                             }).At("http://localhost:1278/ProductService")
                      )
                      .AddBaseAddresses("http://localhost:1278/ProductService")
                      .PublishMetadata()
                         ));
      }
  </code></pre>
  
  <p>As you can see above I've tried to register my service in 3 different ways. To be clear I run only one of those 3 registration code at a time, the others are commented out. For the one which gets config from castle.config here is my castle.config :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;components&gt;
          &lt;component id="TestService"
                         service="IProductService"
                         type="ProductService"
                 lifestyle="transient"&gt;
          &lt;/component&gt;
      &lt;/components&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>And lastly here is my web.config</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  
  &lt;configuration&gt;
      &lt;system.web&gt;
          &lt;compilation debug="true" targetFramework="4.0" /&gt;
      &lt;/system.web&gt;
  
   &lt;system.serviceModel&gt;
    &lt;behaviors&gt;
     &lt;serviceBehaviors&gt;
      &lt;behavior name=""&gt;
       &lt;serviceMetadata httpGetEnabled="true" /&gt;
       &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
      &lt;/behavior&gt;
     &lt;/serviceBehaviors&gt;
    &lt;/behaviors&gt;
    &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
       &lt;services&gt;
           &lt;service name="WCFLibrary.ProductService"&gt;
               &lt;endpoint name ="IProductService_Endpoint" address="http://localhost:1278/ProductService" binding="httpBinding" contract="WCFLibrary.IProductService" /&gt;
           &lt;/service&gt;
       &lt;/services&gt;
   &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Many thanks for any help...</p>