title: C# WCF - net.tcp cannot find endpoint
body: <p>I'm getting the following error message when trying to implement net.tcp WCF in C#:</p>
  
  <blockquote>
    <p>"Could not find default endpoint element that references contract 'EventInterfaceService.IEventInterface' 
    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>On my client side I have the following code:</p>
  
  <pre><code>    private void Initialize(string sInterfaceUrl, string sUserParticipantName)
      {
          EventInterfaceCallbackSink _callbackSink;
          InstanceContext _instanceContext;
          EndpointAddressBuilder _endpointAddressBuilder;
  
  
          _callbackSink = new EventInterfaceCallbackSink();
          _instanceContext = new InstanceContext(_callbackSink);
  
          eventInterfaceClient = new EventInterfaceClient(_instanceContext); //Exception gets thrown here
  
          EndpointIdentity edi = EndpointIdentity.CreateUpnIdentity(sUserParticipantName);
          var endpointAddress = eventInterfaceClient.Endpoint.Address;
  
          EndpointAddressBuilder newEndpointAddress = new EndpointAddressBuilder(endpointAddress);
          newEndpointAddress.Uri = new Uri(sInterfaceUrl);
          newEndpointAddress.Identity = edi;
  
          eventInterfaceClient.Endpoint.Address = newEndpointAddress.ToEndpointAddress();
      }
  </code></pre>
  
  <p>As you can see I get the EndPointAddress as sInterfaceUrl and the UserParticipantName as sUserParticipantName.</p>
  
  <p>For the app.config I have the following:</p>
  
  <pre><code>    &lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;basicHttpBinding&gt;
              &lt;binding name="basicHttpBinding_Interface" closeTimeout="00:01:00"
                  openTimeout="00:01:00" receiveTimeout="Infinite" sendTimeout="00:01:00"
                  allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                  textEncoding="utf-8" useDefaultWebProxy="true" messageEncoding="Text"&gt;
                  &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                      maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
                  &lt;security mode="None"&gt;
                      &lt;transport clientCredentialType="None" /&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/basicHttpBinding&gt;
          &lt;netTcpBinding&gt;
              &lt;binding name="NetTcpBinding_IEventInterface"/&gt;             
          &lt;/netTcpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
          &lt;endpoint address="http://localhost:8732/HTTPWCF/" binding="basicHttpBinding"
              bindingConfiguration="basicHttpBinding_Interface" contract="InterfaceService.IInterface"
              name="basicHttpBinding_Interface" /&gt;
          &lt;endpoint address="net.tcp://localhost:8733/NETTCPWCF/"
              binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IEventInterface"
              contract="EventInterfaceService.IEventInterface" name="NetTcpBinding_IEventInterface"&gt;
          &lt;/endpoint&gt;
      &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>When running this code in a stand-alone client (not the actual application) it works. I can't seem to find out what's wrong. Any tips would be great!</p>
  
  <p>Thanks.</p>
  
  <p>Edit: Is there any way configuring this purely at runtime, so I won't need the app.config? Regarding the comments below, config file may not be found or wrong one is being used.</p>