Consume WCF service from client without WCF Service Library project/assembly reference
<p>The following question may be a duplicate, but there wasn't enough information to answer my question from it.</p>

<p><a href="https://stackoverflow.com/questions/19675194/is-possible-to-access-wcf-service-without-adding-service-reference">Is possible to access WCF Service without adding Service Reference?</a></p>

<p>I've setup a TCP service, using a WCF Service Library project in Visual Studio by following this guide.</p>

<p><a href="https://msdn.microsoft.com/en-us/library/ff649818.aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/ff649818.aspx</a></p>

<p>This worked wonderful if you add a reference to the WCF Service Library project from your client (Windows Forms project).  And add a using statement to the project assembly and use this code.</p>

<pre><code>        TcpService.Service myService = new TcpService.Service();
        myService.GetData(123);
</code></pre>

<blockquote>
  <p>However, I don't want to add a reference to the TcpService assembly in
  the project calling the method "GetData".  Per the very first
  question's answer above.</p>
</blockquote>

<p>So I tried using this code.  I added a reference to System.ServiceModel (and a using directive) to resolve most of the errors.  But now it says "The type or namespace name 'ServiceContract' could not be found (are you missing a using directive or an assembly reference?)".  Do I need to modify the App.Config in my service, or add any other code (with regard to 'ServiceContract') to the project calling this code below?</p>

<pre><code>        BasicHttpBinding binding = new BasicHttpBinding();
        EndpointAddress address = new EndpointAddress("net.tcp://localhost:8523/Service");
        ChannelFactory&lt;ServiceContract&gt; factory = new ChannelFactory&lt;ServiceContract&gt;(binding, address);
        ServiceContract channel = factory.CreateChannel();
        channel.GetData(123);
</code></pre>

<p><a href="https://i.stack.imgur.com/t5GqY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t5GqY.png" alt="enter image description here"></a></p>

<p>Note: I renamed the default Service1.cs and the default interface IService1.cs to Service.cs and IService.cs.  Without the "1" as the suffix, based on the instructions.  I also renamed WcfServiceLibrary1 to TcpService in my code.  Also, in .NET 4.5, I didn't need this line of code at all for it to work.  This .Close() errored out.</p>

<pre><code>myService.Close();
</code></pre>

<p>I added a Service Reference in Visual Studio, by right clicking the Project > Add > Service Reference.  But I get an error there.</p>

<p><a href="https://i.stack.imgur.com/vSgiB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vSgiB.png" alt="enter image description here"></a></p>

<p>Error in 2nd dialog:</p>

<blockquote>
  <p>The URI prefix is not recognized. Metadata contains a reference that
  cannot be resolved: 'net.tcp://localhost:8523/Service'. Could not
  connect to net.tcp://localhost:8523/Service. The connection attempt
  lasted for a time span of 00:00:01.0011001. TCP error code 10061: No
  connection could be made because the target machine actively refused
  it 127.0.0.1:8523.  No connection could be made because the target
  machine actively refused it 127.0.0.1:8523 If the service is defined
  in the current solution, try building the solution and adding the
  service reference again.</p>
</blockquote>