title: "Could not find endpoint element with name..."
body: <p>Sorry for the long problem statement...I've spent two days debugging and have a lot of notes...</p>
  
  <p>I have a WCF data service and another process trying to connect to it as a client via TCP and/or HTTP.</p>
  
  <p>I have a VERY simple test client app that seems to connect fine, but the more complicated production app cannot connect (neither TCP or HTTP).  In both client projects, I let Visual Studio 2008 generate the app.config by using "Add Service Reference" and letting it pull metadata from the data service.</p>
  
  <p>Here is the code for the simple test client that works:</p>
  
  <pre><code>using Client.MyDataService;
  
  namespace Client
  {
      class Program
      {
          static void Main(string[] args)
          {
              MyDataServiceClient client = new MyDataServiceClient("net.tcp");
  
              client.GetRecords();
          }
      }
  }
  </code></pre>
  
  <p>Here is the code for the more complicated, production client:</p>
  
  <p>DataServiceManager.cs:</p>
  
  <pre><code>using MyServer.MyDataService;
  
  namespace MyServer.DataServiceBridge
  {
      class DataServiceManager
      {
          MyDataServiceClient dataServiceClient = new MyDataServiceClient("net.tcp");
  }
  }
  </code></pre>
  
  <p>In main process:</p>
  
  <pre><code>DataServiceManager d = new DataServiceManager();
  </code></pre>
  
  <p>Here is the app.config file for both simple client and production client:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;netTcpBinding&gt;
                  &lt;binding name="net.tcp" closeTimeout="00:01:00" openTimeout="00:01:00"
                      receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
                      transferMode="Buffered" transactionProtocol="OleTransactions"
                      hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                      maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                      maxReceivedMessageSize="65536"&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="Transport"&gt;
                          &lt;transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /&gt;
                          &lt;message clientCredentialType="Windows" /&gt;
                      &lt;/security&gt;
                  &lt;/binding&gt;
              &lt;/netTcpBinding&gt;
          &lt;/bindings&gt;
          &lt;client&gt;
              &lt;endpoint address="net.tcp://localhost:8888/MyDataService"
                  binding="netTcpBinding" bindingConfiguration="net.tcp" contract="MyDataService.IMyDataService"
                  name="net.tcp"&gt;
                  &lt;identity&gt;
                      &lt;userPrincipalName value="COMPUTER_NAME\Username" /&gt;
                  &lt;/identity&gt;
              &lt;/endpoint&gt;
          &lt;/client&gt;
      &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <ul>
  <li><p>In MyServer's bin\Debug\ folder is
  MyServer.exe, app.config.</p></li>
  <li><p>In MyDataSeriviceHost's bin\Debug\
  folder is MyDataService.exe,
  app.config, and
  MyDataSeriviceHost.exe.config.
  app.config and
  MyDataSeriviceHost.exe.config are
  identical.</p></li>
  </ul>
  
  <p>Here is the error message:</p>
  
  <pre><code>An exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll but 
  was not handled in user code
  
  Additional information: Could not find endpoint element with name 'net.tcp' and contract
   'MyDataService.IMyDataService' 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 name could be found in the client element.
  </code></pre>
  
  <p>Any ideas what is going on?  I've pretty much exhausted Google. :-(</p>