title: WCF: Could not find default endpoint element that references contract 'IService' in the ServiceModel client configuration section. when hosting in IIS
body: <p>I have a WCF service which is being hosted in IIS. I have a WCF client also (a console application). I have used <code>svcutil</code> to build the proxy class and configuration file and then added those to my client project. It built properly. But when I tried to run the program, it is throwing the below exception</p>
  
  <blockquote>
    <p>Could not find default endpoint element that references contract 'IService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.</p>
  </blockquote>
  
  <p>//My client program code</p>
  
  <pre><code>namespace MyFirstWCFClient
  {
   class Program
   {
      static void Main(string[] args)
      {
          ServiceClient objClient = new ServiceClient();
          Console.WriteLine("Client calling the service....");
  
          string strName=Console.ReadLine();
          Console.WriteLine(objClient.HelloWorld("Shyju"));
          Console.Read();
  
      }
   }
  }
  </code></pre>
  
  <p>Output.config file of my client is</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="utf-8"?&gt;
     &lt;configuration&gt;
      &lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;wsHttpBinding&gt;
              &lt;binding name="WSHttpBinding_IService" closeTimeout="00:01:00"
                  openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                  bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                  messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                  allowCookies="false"&gt;
                  &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                      maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
                  &lt;reliableSession ordered="true" inactivityTimeout="00:10:00"
                      enabled="false" /&gt;
                  &lt;security mode="Message"&gt;
                      &lt;transport clientCredentialType="Windows" proxyCredentialType="None"
                          realm="" /&gt;
                      &lt;message clientCredentialType="Windows" negotiateServiceCredential="true"
                          algorithmSuite="Default" establishSecurityContext="true" /&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/wsHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
          &lt;endpoint address="http://localhost/IISHostedserviceTest/Service.svc"
              binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService"
              contract="IService" name="WSHttpBinding_IService"&gt;
              &lt;identity&gt;
                  &lt;dns value="localhost" /&gt;
              &lt;/identity&gt;
          &lt;/endpoint&gt;
       &lt;/client&gt;
   &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>and in the web.config of my service has the below configuration</p>
  
  <pre><code>   &lt;system.serviceModel&gt;
     &lt;services&gt;
      &lt;service name="Service" behaviorConfiguration="ServiceBehavior"&gt;
      &lt;!-- Service Endpoints --&gt;
      &lt;endpoint address="http://localhost/IISHostedserviceTest/Service.svc" binding="wsHttpBinding" contract="IService"&gt;
        &lt;!-- 
            Upon deployment, the following identity element should be removed or replaced to reflect the 
            identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
            automatically.
        --&gt;
        &lt;identity&gt;
          &lt;dns value="localhost"/&gt;
        &lt;/identity&gt;
      &lt;/endpoint&gt;
      &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  &lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="ServiceBehavior"&gt;
        &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt;
        &lt;serviceMetadata httpGetEnabled="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>I used this(<a href="http://www.wcftutorial.net/WCF-IIS-Hosting.aspx" rel="nofollow noreferrer">http://www.wcftutorial.net/WCF-IIS-Hosting.aspx</a>) tutorial to have a try on WCF.</p>
  
  <p>Can anyone guide me how to resolve this ?</p>