title: WCF, ServiceHost - CreateChannel, don't create new remote instance
body: <p>I got a usual WCF service set up like this:</p>
  
  <pre><code>private ServiceHost serviceHost = null;
  
  protected override void OnStart(string[] args)
  {
      if (serviceHost != null)
          serviceHost.Close(); 
  
      Uri[] baseAddress = new Uri[]{
      new Uri("net.pipe://localhost")};
  
      string PipeName = "DatabaseService";
  
      serviceHost = new ServiceHost(typeof(Kernel), baseAddress); // Kernel implements IDatabase
  
      serviceHost.AddServiceEndpoint(typeof(IDatabase), new NetNamedPipeBinding(), PipeName);
  
      serviceHost.Open();
  }
  
  protected override void OnStop()
  {
     if (serviceHost != null &amp;&amp; serviceHost.State != CommunicationState.Closed)
      {
          serviceHost.Close();
          serviceHost = null;
      }
  } 
  </code></pre>
  
  <p>From this code, i guess, one instance of "Kernel" is created, because I got this service running only once.</p>
  
  <p>I create a proxy Object using the ChannelFactory like this:</p>
  
  <pre><code>pipeFactory = new ChannelFactory&lt;IDatabase&gt;(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/DatabaseService"));
  m_Database = pipeFactory.CreateChannel();
  </code></pre>
  
  <p>I have to say, that my Kernel instance access a local file, and therefore it's very important I got only once physical instance of this class. I want my service to take care of that but here come's my problem.</p>
  
  <p>While the service is running and a single channel is created and active, a second client comes up and wants to create a channel too. That works properly but if I start using the proxy Object a FaultException is thrown because a second instance of my Kernel class is created.</p>
  
  <p>Therefore I'm guessing that an instance of the Kernel class is created by every CreateChannel call. </p>
  
  <p>Is it possible to avoid the creation of a new instance and return always a reference to a single Kernel class instance when CreateChannel is called?</p>
  
  <p>Regards,
  inva</p>