title: How do I consume a net.tcp service in asp.net core 2.1
body: <p>I'm building an asp.net core 2.1 web application and I need to call an old net.tcp endpoint in order to get details about a booking. The endpoint is configured like so in the web.config of another old application:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
  &lt;behaviors&gt;
    &lt;endpointBehaviors&gt;
      &lt;behavior name="Behaviors.EndpointBehavior"&gt;
        &lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt;
      &lt;/behavior&gt;
    &lt;/endpointBehaviors&gt;
  &lt;/behaviors&gt;
  &lt;bindings&gt;
    &lt;netTcpBinding&gt;
      &lt;binding name="unsecuredLargeTcpBuffer" maxBufferSize="20000000" maxReceivedMessageSize="20000000"&gt;
        &lt;readerQuotas maxArrayLength="20000000" maxBytesPerRead="20000000" maxStringContentLength="10000000" /&gt;
        &lt;security mode="None" /&gt;
      &lt;/binding&gt;
    &lt;/netTcpBinding&gt;
  &lt;/bindings&gt;
  
  &lt;client&gt;      
    &lt;endpoint address="net.tcp://us-ap-contoso1:12345/Bookings" binding="netTcpBinding" bindingConfiguration="unsecuredLargeTcpBuffer" behaviorConfiguration="Behaviors.EndpointBehavior" contract="Contoso.Contracts.IBookingService" /&gt;     
  &lt;/client&gt;
  </code></pre>
  
  <p></p>
  
  <p>In aspnet core I believe can't use this file based configuration, but need to do it programmatically. I've tried using svcutil to generate a service reference, but this does not work with the net.tcp service. </p>
  
  <p>I've tried to call setup a web.config file with the above configuration and call the endpoint like this </p>
  
  <pre><code>public Booking FindBooking(string name, string number)
      {
          var proxy = new BookingSearchServiceProxy();
  
          try
          {
              var query = new BookingFieldQuery
              {
                  BookingNumber = number,
                  LastName = name
              };
  
              Booking booking = proxy.FindSingle(query);
  
              return booking;
          }
          catch (Exception ex)
          {
              //log here
          }
          finally
          {
              proxy.CloseSafely();
          }
  
          return null;
      }
  </code></pre>
  
  <p>But it throws an exception</p>
  
  <pre><code>System.PlatformNotSupportedException: Configuration files are not supported.
  </code></pre>
  
  <p>How do I go about this?</p>
  
  <p>I would be grateful for any advice you can give.</p>