title: Registering WCF service in Unity Container
body: <p>I have a wcf service library that is hosted in a windows service. I need to intercept calls to 
  Service methods. For this case it is suggested to register WCF into Unity container as can be seen in this link</p>
  
  <p><a href="http://weblogs.asp.net/fabio/archive/2009/03/24/inversion-of-control-with-wcf-and-unity.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/fabio/archive/2009/03/24/inversion-of-control-with-wcf-and-unity.aspx</a></p>
  
  <p>I am trying to implement a similar approach by Unity.WCF assembly from Codeplex.I could not understand where to put my container configuration or bootstrapper in wcf service library(or windows service). There is not a solid sample (vs solution) provided. </p>
  
  <p>My Windows Service Host</p>
  
  <pre><code>    private UnityServiceHost _serviceHost = null;
      private readonly UnityContainer _container;
  
  
      public Service() {
          InitializeComponent();
          _container = new UnityContainer();
          _container.AddNewExtension&lt;Interception&gt;();
          _container.RegisterType&lt;ISecurityRepository, SecurityRepository&gt;();
          _container.Configure&lt;Interception&gt;().SetDefaultInterceptorFor&lt;ISecurityRepository&gt;(new TransparentProxyInterceptor());
      }
  
      protected override void OnStart(string[] args) {
  
          //SecurityService
          if (_serviceHost != null) {
  
              _serviceHost.Close();
          } else {
              _serviceHost = new UnityServiceHost(_container, typeof(SecurityRepository));
              _serviceHost.Open();
          }
  
      }
  
      protected override void OnStop() {
  
          //SecurityService
          if (_serviceHost != null) {
  
              _serviceHost.Close();
              _serviceHost = null;
          }
      }
  </code></pre>
  
  <p>My Service Contract</p>
  
  <pre><code>[ServiceContract(SessionMode = SessionMode.Required)]
  public interface ISecurityRepository
  {
  
      [OperationContract(IsInitiating = true)]
      IList&lt;vNavigationTree&gt; GetNavigationTree(string ticket);
  
      [OperationContract(IsInitiating = true)]
      string GetSessionGuid(string userName, string IP, string machineName);
  }
  </code></pre>
  
  <p>In this case it seems that interceptor does not work. Briefly what I need is a sample project in which the WCF Service is registered to DI container and the Service methods are intercepted. </p>