Posts Tagged ‘WCF’

Hosting a WCF in IIS

To my understanding the pros and cons of hosting a WCF in IIS are:

Pros: have access to the many built-in features available with IIS such as process recycling and message-based activation.

Cons: No support for TCP, named pipes, and MSMQ. In addition an IIS server is needed.

For many ASP.Net applications hosting services in IIS is the best choice.

The following article is walkthrough How to: Host a WCF Service in IIS.

Categories: WCF Tags: ,

WCF: Install IIS after .Net 3

June 3, 2009 1 comment

In order to host a WCF service in IIS, WCF should be registered correctly with IIS. If you install .Net 3 (or 3.5) after IIS this will happen automatically; however, if you install IIS on a system which already containz .Net 3 then a manual registration for WCF is needed as explain by (

You can do this as follows, depending on your operating system:

  • Windows XP SP2 and Windows Server 2003: Use the ServiceModelReg.exe tool to register WCF with IIS: To use this tool, type ServiceModelReg.exe /i /x at a command prompt. The tool can be found in the following location: %SystemRoot%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\
  • Windows Vista: Install the Windows Communication Foundation Activation Components subcomponent of the .NET Framework 3.0. To do this, in Control Panel, click Add or Remove Programs and then Add/Remove Windows Components. This activates the Windows Component Wizard.

WCF HTTP Activation

After registering the WCF it may still not work as result of .Net 2 registration issue with IIS. In case of recieving the following error:

System.Web.Hosting.HostingEnvironmentException: Failed to access IIS metabase

The fix is explained in Microsoft support article:

Follow the steps given below to fix this error

(1) Go to Start | Control Panel | Add and Remove Programs

(2) Click on the entry titled Microsoft .NET Framework 2.0 and select Change/Remove. The Microsoft .NET Framework 2.0 Setup dialog box opens up. 

(3) Select the option titled Repair and the setup automatically performs the required repair work.

(4) You will be prompted to reboot the system after the completion of the process.

(5) Run the affected ASP.NET 2.0 application once again and the application should work fine without any problems.

Categories: WCF Tags: , , , ,

Configuring a client endpoint

The followings are related (useful) articles (in addition to my notes) about configuring a WCF Client application:

MSDN Article 1: Client Configuration


The following shows the example in the MSDN article excluding all attributes and values. This configuration shows the overall structure of the xml elements.

<?xml version="1.0" encoding="utf-8"?>
          <endpoint >


//The behavior section references by the behaviorConfiguration endpoint attribute.


MSDN Article 2. Specifying an Endpoint Address

  • Each endpoint has a address associated to it. There are two ways to specify the address: In code and in the configuration file.
Categories: WCF Tags: , , , ,

Err: Another application has already registered this URL with HTTP.SYS

May 16, 2009 11 comments

While running a WCF solution (including a service project and a service host) the following error can occur:

“HTTP could not register URL http://+:8080/MyServiceName/. Another application has already registered this URL with HTTP.SYS.”

I faced this problem when I tried to run some of the practice exercises for MCTS 70-503 Training Kit.

Cause: When you set the solution starting program to the service host, visual studio still runs the WCF SVC Hostt before your service host project and it put a listener on the port before your host application does. This only happen when you run the solution in the debug mode. In the Start Withouth Debuging (Ctrl +F5)  mode this does not happen.

Solution: I thought that WCF SVC Host could be disabled from the Service project>Properties>Debug Tab>Command Line Argument. It is a natural place to look for this and in fact I thought you should be able to remove the predefine value in the box “/client:”WcfTestClient.exe” and stop WCF SVC Host to run. However, it does not work. For more information you can read the following post on MSDN forum:Disabling WcfSvcHost when self-hosting. So I found the only way around this problem, is renaming the App.config file for the Service project to something like “App.config.temp”. This certainly stop executing WCF Test Client.

Categories: WCF Tags: ,