0

I am using WCF with NetTcpBinding on a solution where both client and server are windows forms. The service is hosted by one of them. I am using VS.2012.

On the server side I have several service contracts (related) all of which are implemented in a single service class. Like this:

public class MyService : IServiceA, IServiceB
{
}

and they should be accessible via net.tcp://localhost:4545/control/ which would lead to the following service addresses:

 IServiceA (endpoint alphaEP) : net.tcp://localhost:4545/control/ASvc/
 IServiceB (endpoint betaEP)  : net.tcp://localhost:4545/control/BSvc/

And when I use svcutil.exe to generate the client stuff I see that it generates TWO service client classes, one for each interface, so when I use the ServiceBClient it generates an exception inidicating it could not find a 'betaEP' with contract 'IServiceB' even though the app.config has the same binding configuration and has both endpoints defined

  <bindings>
    <netTcpBinding>
      <binding name="alphaEP">
        <reliableSession enabled="true" />
        <security mode="None" />
      </binding>
      <binding name="betaEP">
        <reliableSession enabled="true" />
        <security mode="None" />
      </binding>
    </netTcpBinding>
  </bindings>

and this

  <client>
    <endpoint address="net.tcp://localhost:4545/control/ASvc"
        binding="netTcpBinding" bindingConfiguration="alphaEP"
        contract="CodeDom.IServiceA" name="alphaEP">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="net.tcp://localhost:4545/control/BSvc"
            binding="netTcpBinding" bindingConfiguration="betaEP" contract="CodeDom.IServiceB"
            name="betaEP">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
  </client>

Why can't it find the endpoint if this client app.config was generated by svcutil.exe based on the server configuration?

Why does it generates two client classes instead of a single one? would that be the source of the problem? I have multiple related services to expose and I don't want to occupy more than one port on that. Do note, this is Net TCP Binding.

Lord of Scripts
  • 3,579
  • 5
  • 41
  • 62
  • 1
    I could not reproduce the issue. But to answer your question - Each client class is generated to implement a specific service contract which is by design. Since both your client and service are projects within the same solution, you may consider the option of using ChannelFactory<> to perform calls. Here are some pointers : http://blogs.msdn.com/b/juveriak/archive/2008/02/03/using-channels-vs-proxies-in-wcf.aspx, http://msdn.microsoft.com/en-us/library/ms734681.aspx. Advantage of using this is you do not need to use svcutil to generate proxies which reduces cluttering. – Praburaj Feb 20 '13 at 20:43
  • If you still find issues in getting it working, please upload a repro somewhere for us to have a look and suggest. – Praburaj Feb 20 '13 at 20:44
  • Managed to get it working with the proxies using the separate proxy classes. Just a matter of getting used to it. But now I will consider using the ChannelFactory<> mentioned in the link since it would be handier for me to share a single DLL rather than creating/updating a proxy dll. My only remaining problem is always getting the Service Host pop up indicating there was a processor/platform mismatch even though all known DLLs are x86. Just can't get rid of it. But at least this is cleared out. thanks a lot. – Lord of Scripts Feb 21 '13 at 23:56

0 Answers0