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 (http://msdn.microsoft.com/en-us/library/aa751792.aspx):
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.
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.