title: WCF: What is a ServiceHost?
body: <p>As I'm currently learning to use WCF Services, I am constantly encountering tutorials on the internet which mention using a <code>ServiceHost</code> when using a WCF Service.  </p>
  
  <p><strong>What exactly is this <code>ServiceHost</code> ?</strong></p>
  
  <hr>
  
  <p>In my current project I am using a WCF Service and having a reference to it from my app and whenever I want to consume it from my app I just instantiate its <code>ServiceClient</code> like such:</p>
  
  <pre><code>new MusicRepo_DBAccess_ServiceClient(new InstanceContext(instanceContext), customBinding, endpointAddress);
  </code></pre>
  
  <p>And then access my web methods (<code>OperationContract</code>s) from that instance (obviously opening it before consuming the method and closing it afterwards with <code>Open</code> and <code>Close</code>)</p>
  
  <p>My WCF service is host in my IIS and I just access the <code>.svc</code> from my app to instantiate the <code>ServiceClient</code>.</p>
  
  <p>So why and where is <code>ServiceHost</code> used?</p>