Sony Arouje

a programmer's log

Hosting Pipe/TCP based WCF service in Windows Activation Service

with 8 comments

In this post I will give a brief idea of how to host pipe/TCP based WCF service using WAS. Before WAS, we host TCP/pipe based service using custom hosting. That means we need to write an application ourself to host our services. Including me most of the deves wrote applications to host WCF services, so am not going in detail of custom hosting.

What’s WAS or Windows Process Activation services? WAS is part of IIS that enable us to host non http based services. I am not going much details of WAS. Here I am more concentrating on how to configure WAS and run a small test application.

Configure WAS in our System

By default WAS will be disabled. We need to enable it our self, let’s see how we can do that.

1. Goto control panels –> Programs and Features. Click on ‘Turn Windows Feature on or off’ link. It will open a window as shown below. From the list select Windows Process Activation Service and make sure all the child elements also selected.


2. Also scroll up and Select ‘Microsoft .NET Framework’ as shown below. Make sure all the child elements also selected, if not select it.


We enabled Windows Activation Service in our system. Let’s go ahead and create a WCF service.

For testing purpose I created a WCF service to add two numbers. Let’s see the service configuration

          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>          
        <behavior name="calcServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      <service name="ServiceLayer.CalculatorService" behaviorConfiguration ="calcServiceBehaviour">
        <endpoint name="CalculatorService" address="" binding="netTcpBinding"
                  contract="ServiceLayer.ICalc" />
        <endpoint name="CalculatorService" address="" binding="basicHttpBinding"
          contract="ServiceLayer.ICalc" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

As you can see I have two endpoints HTTP and TCP. If we host this in IIS and try to browse it will throw error. Still some configuration is left behind. Let’s finish that config too.

Goto IIS configuration file. You can find that in C:\Windows\System32\inetsrv\config. Open applicationHost.config in notepad. You can see the screen shot below.


Search for bindings, and you can see the marked section as shown above. By default you could only see HTTP binding and rest of the binding you can add it. If other binding exist then we are good. If not copy paste the below bindings to the config file under Bindings section.

<binding protocol="net.tcp" bindingInformation="808:*" />

<binding protocol="net.pipe" bindingInformation="*" />

<binding protocol="net.msmq" bindingInformation="localhost" />

<binding protocol="msmq.formatname" bindingInformation="localhost" />

Next step is create an application in IIS. I named the application as Calculator. Right click on the newly created Application and select Manage Application –> Advanced Settings…, you will get a popup as shown below


In the above popup you need to enable the protocol this application going to support. As you can see the marked section, I added http, pipe and tcp protocols for my Calculator service. We can enter the protocols like http,net.pipe,net.tcp (separated by comma).

Once again go back to applicationHost.config file and verify the Sites section. You can see the newly created site with protocols it supports. See the screen shot below


We are done with our configuration and the service is ready. Lets go ahead and browse our svc file. If it’s not throwing any error then we are good to go.

Note: If we install IIS after the installation of Visual studio then it will throw some an error like Error 500.21 Handler "svc-Integrated" has a bad module "ManagedPipelineHandler" in its module list". If you are getting this error then run aspnet_regiis.exe –i  in VS command prompt.

Create an application to test our service, I created a winform app to test it. Also we need to create a proxy to access the service. We can create the proxy using svcutil. The util will create a config file as well as shown below.

        <binding name="CalculatorService1" closeTimeout="00:01:00" openTimeout="00:01:00"
            receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
        <binding name="CalculatorService" 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"
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
              enabled="false" />
          <security mode="Transport">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows" />
      <endpoint address="net.tcp://sonyarouje/Calculator/CalculatorService.svc"
          binding="netTcpBinding" bindingConfiguration="CalculatorService"
          contract="ICalc" name="CalculatorService">
          <servicePrincipalName value="host/sonyarouje" />
      <endpoint address="http://localhost/Calculator/CalculatorService.svc"
          binding="basicHttpBinding" bindingConfiguration="CalculatorService1"
          contract="ICalc" name="CalculatorService1" />


Add an app.config to our test app and copy paste the config generated by svcutil. As you can see we have two endpoint http and tcp and we can use any of those. I called the service in button click and the code is as follows

CalcClient calc = new CalcClient("CalculatorService");
int x = Convert.ToInt32(txtX.Text);
int y = Convert.ToInt32(txtY.Text);
MessageBox.Show (string.Format("Sum is {0}", calc.Sum(x,y )));

While creating the object of service proxy we can pass the endpoint name. Here I am passing CalculatorService and it is the name of tcp endpoint. So the communication will establish through TCP. If we pass CalculatorService1 it will use the http end point.

Hope my post will be helpful for some one. if any Comments or Suggestion, pls post it in the comment section.

Download Test Projects

Written by Sony Arouje

April 3, 2011 at 3:19 pm

Posted in .NET, WCF

Tagged with , , , ,

8 Responses

Subscribe to comments with RSS.

  1. This is very good information for me. Author – respect!


    April 4, 2011 at 2:34 pm

  2. I think you’ll want to put a twitter button to your website. I just bookmarked this url, but I had to make this manually. Simply my suggestion.

    Car Hire Alicante

    April 12, 2011 at 6:16 pm

    • Hi,
      The twitter button exist at the bottom of each post, it’s the first one in the Share this section. Could you pls verify once again.

      Sony Arouje

      April 12, 2011 at 7:46 pm

  3. Thank . it work for me

    soma Namerjee

    January 3, 2012 at 1:13 pm

  4. I don’t get a web.config as yours. And I can’t add end points as you eretned in the screen shot. I had created a wcf services first and want them to response with json.Any idea??


    November 18, 2012 at 1:14 am

    • By default you wont get a web config. You have to add it using Add new item. I am not sure why you cant add endpoints. You can use a REST WCF service for JSON response.

      Sony Arouje

      November 19, 2012 at 10:27 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: