title: dependency injection on wcf throwing exception
body: <p>i use simple injector. as their documentation explained i have implemented <code>WcfServiceFactory</code> </p>
  
  <pre><code>public class WcfServiceFactory : SimpleInjectorServiceHostFactory
  {
      protected override ServiceHost CreateServiceHost(Type serviceType,
      Uri[] baseAddresses)
      {
          var host = new SimpleInjectorServiceHost(DependencyConfig.Container, serviceType, baseAddresses);
          return host;
      }
  } 
  public class DependencyConfig
  {
      static DependencyConfig()
      {
          var container = new Container();
          container.Options.DefaultScopedLifestyle = new WcfOperationLifestyle();
          container.Register(typeof (IRepositoryAsync&lt;&gt;), typeof (Repository&lt;&gt;));
          container.Verify();
          Container = container;
      }
  
      public static Container Container { get; set; }
  
  }
  </code></pre>
  
  <p>i changed my TrackerService.svc to this</p>
  
  <pre><code>&lt;%@ ServiceHost Language="C#" Debug="true" Service="TimeTrackerService.TrackerService" CodeBehind="TrackerService.svc.cs" Factory="SimpleInjector.Integration.Wcf.SimpleInjectorServiceHostFactory,SimpleInjector.Integration.Wcf" %&gt;
  </code></pre>
  
  <p>and my web.config</p>
  
  <pre><code> &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;wsHttpBinding&gt;
          &lt;binding name="WSHBBinding" /&gt;
        &lt;/wsHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;services&gt;
        &lt;service name="TimeTrackerService.TrackerService"&gt;
          &lt;endpoint address="" binding="basicHttpBinding" contract="TimeTrackerService.ITrackerService"&gt;
            &lt;identity&gt;
              &lt;dns value="localhost" /&gt;
            &lt;/identity&gt;
          &lt;/endpoint&gt;
  
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:8878/TimeTrackerService/TrackerService/" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior&gt;
            &lt;!-- To avoid disclosing metadata information, 
            set the values below to false before deployment --&gt;
            &lt;serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" /&gt;
            &lt;!-- To receive exception details in faults for debugging purposes, 
            set the value below to true.  Set to false before deployment 
            to avoid disclosing exception information --&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="False" /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>when i try to run the service it throws exception:</p>
  
  <blockquote>
    <p>The operation failed. Please call the SimpleInjector.Integration.Wcf.SimpleInjectorServiceHostFactory.SetContainer(Container) method supplying the application's SimpleInjector.Container instance during application startup (for instance inside the Application_Start event of the Global.asax). In case you're running on non-HTTP protocols such as net.tcp and net.pipe that is supported by the Windows Activation Service (WAS), please see the WCF integration documentation: <a href="https://simpleinjector.org/wcf" rel="nofollow">https://simpleinjector.org/wcf</a>.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/yDobo.png" rel="nofollow"><img src="https://i.stack.imgur.com/yDobo.png" alt="enter image description here"></a></p>
  
  <p>i have no idea where to call <code>SetContainer(container)</code> method. did i do any mistake ?</p>