Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use netTcpBinding with the VS 2008 development server?

Is it possible to have a WCF service configuration like this:

  <service behaviorConfiguration="WcfService1.Service1Behavior"
    name="WcfService1.Service1">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
      contract="WcfService1.IService1">
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
      contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost/netTcpService" />
      </baseAddresses>
    </host>
  </service>

And have it hosted on the ASP.NET development server that comes with Visual Studio 2008, or do I necessarily have to host the service in IIS 7 or self-host it in a managed application/Windows service?

Thank you for your insights!

like image 373
Édgar Sánchez Gordón Avatar asked Dec 23 '22 10:12

Édgar Sánchez Gordón


1 Answers

IIS6 and the built-in Cassini web server both support only http, sorry.

You'll have to either self-host your service in e.g. a console app, or host it in IIS7 in order to use NetTCP.

VS2008 SP1 also comes with a WCF Test Host app that can be used for those purposes, and it supports NetTCP and all other protocols as well.

It's called WcfSvcHost.exe and should be found in your C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE directory. You can specify a DLL containing your service implementation and a config file for it, and it'll load your service and host it for you.

MSDN documentation for the WcfSvcHost is here:
http://msdn.microsoft.com/en-us/library/bb552363.aspx

Here's what it'll look like in your environment:

alt text

and here's the WcfTestClient.exe connected to that hosted service - note the netTcp endpoint:

alt text

To set it up in Visual Studio, use the WCF service library project's "Properties" tab and pick to launch WcfSvcHost.exe as the external program and supply the correct command-line arguments like this:

alt text

Now if you press F5 to run the class library containing your WCF service, it'll launch the test host and host your service library in there, ready to be tested.

Marc

like image 84
marc_s Avatar answered Dec 27 '22 19:12

marc_s