Hosting WCF NetTCP on IIS WAS

This post will walk you through setting up and running a WCF service using NetTcp binding on Windows Process Activation Service (WAS). WAS is a new feature of IIS 7.0 and makes it possible to host WCF services beyond HTTP and without installing the whole of IIS components. If you are interacting with services within the same infrastructure, you might opt to use NetTcp over HTTP binding; net.tcp being faster since your soap message is not wrapped inside a HTTP request. In this example I have a Stockmarket application with a net.tcp endpoint and a http mex endpoint to expose the metadata. I will be hosting it under root "Default Web Site/StockMarket"


1. The first step is you configure your WCF service to have NetTcp binding.  

 <service name="StockMarket.StockService"
 address="" binding="netTcpBinding"
 address="mex" binding="mexHttpBinding"
 multipleSiteBindingsEnabled="true" />


2. The next step is to set up your system to host non-HTTP activation endpoints. For that you may follow this MSDN post. Specifically these are the steps you need to perform:

 Install WCF non-activation endpoints

  1. Click the Start button, and then click Control Panel.
  2. Click Programs, and then click Programs and Features.
  3. On the Tasks menu, click Turn Windows features on or off.
  4. Find the .NET Framework 3.0 or 3.5 node, select and then expand it.
  5. Select the WCF Non-Http Activation Components box and save the setting.

 To configure the WAS to support TCP activation

To support net.tcp activation, the default Web site must first be bound to a net.tcp port. You can do this by using Appcmd.exe, which is installed with the IIS 7.0 management toolset. In an administrator-level Command Prompt window,run the following command. 

 %windir%\system32\inetsrv\appcmd.exe set site "Default Web site" -+bindings.[protocol='net.tcp',bindingInformation='808:*'] 

This command adds a net.tcp site binding to the default Web site listening on TCP port 808 with any host name. Although all applications within a site share a common net.tcp binding, each application can enable net.tcp support individually.

To enable net.tcp for the application, run the following command from an administrator-level command prompt.

 %windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/<WCF Application>" /enabledProtocols:http,net.tcp

 This command enables the /<WCF Application> application to be accessed using both http://localhost/<WCF Application> and net.tcp://localhost/<WCFApplication>.


3. Once this is done, publish your service and navigate to http://localhost:8000/StockMarket/StockService.svc to get the metadata. You may encounter an error message as follows.

 Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089′.  

 This error occurs if you install .Net 4.0 on IIS and enable .Net 3.0 or 3.5 features. This error also occurs if you run on .net 4.0 application pool. To resolve this issue, run the following from command line: 


 The aspnet_regiis.exe file can be found in either "%windir%\Microsoft.NET\Framework\v4.0.30319" (x86) or "%windir%\Microsoft.NET\Framework64\v4.0.30319"  (x64)


That's it. You should be now running your net.tcp based WCF service on IIS WAS. Happy coding. :)