title: IMetadataExchange MEX endpoint error when hosting WCF service in console application
body: <p>I have a WCF service. I am trying to host the service in a console application.</p>
  
  <p>I am following all the directions <a href="http://bloggingabout.net/blogs/dennis/archive/2006/10/18/WCF-Part-0-_3A00_-Introduction.aspx" rel="nofollow noreferrer">here</a>.</p>
  
  <p>Now everything compiles fine, but I get an exception at runtime.</p>
  
  <blockquote>
    <p>The contract name 'IMetadataExchange' could not be found in the list of contracts implemented by the service Indexer. Add a ServiceMetadataBehavior to the configuration file or to the ServiceHost directly to enable support for this contract.</p>
  </blockquote>
  
  <p>Now in the directions, I am instructed to add</p>
  
  <pre><code>&lt;endpoint binding="mexHttpBinding" bindingConfiguration=""
  name="http://localhost:8080/myservice/MEX/" contract="IMetadataExchange" /&gt;
  </code></pre>
  
  <p>I don't have IMetadataExchange anywhere in my WCF service or the host console application.</p>
  
  <p>Where does the exception come from? Is there a reference I am missing?</p>
  
  <p>This is my console program</p>
  
  <pre><code>namespace WcfConsoleHost
  {
      class Program
      {
          static void Main(string[] args)
          {
              Type type = typeof(myservice);
              using (ServiceHost host = new ServiceHost(type))
              {
  
                  host.Open();
                  Console.WriteLine("The service is available. Press any key...");
                  Console.ReadKey();
                  host.Close();
              }
          }
      }
  }
  </code></pre>
  
  <p>My WCF service just has an Interface with the contracts and then the implemetation in the myservice class.</p>
  
  <p>Below is my entire app.config.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;system.serviceModel&gt;
          &lt;behaviors&gt;
              &lt;serviceBehaviors&gt;
                  &lt;behavior name="ServiceBehavior"&gt;
                      &lt;serviceMetadata /&gt;
                  &lt;/behavior&gt;
              &lt;/serviceBehaviors&gt;
          &lt;/behaviors&gt;
          &lt;services&gt;
              &lt;service name="myservice"&gt;
                  &lt;endpoint address="http://localhost:8080/myservice/"
                   binding="basicHttpBinding"
                      bindingConfiguration="" contract="myservice.Ims" /&gt;
                  &lt;endpoint binding="mexHttpBinding" bindingConfiguration=""
                   address="http://localhost:8080/myservice/MEX/"
                      contract="IMetadataExchange" /&gt;
              &lt;/service&gt;
          &lt;/services&gt;
      &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>