Hosting a WCF Service in IIS 7 on Windows7

I recently set out to host a WCF service in IIS 7 on my development machine (running Windows 7).  I had created the application in .NET 4.  After doing the obvious and reviewing a number of blog posts and forums I was able to get it working.

I have to admit that I was somewhat disappointed with the quality of the MS articles that I found from my Google searches.  I'm documenting the steps here in case someone else runs into some of the difficulties I encountered.

1. Create the directory that will contain the deployed application.  I used c:\projects\wcftrial.
2. Set the permissions on this directory.  Ensure Network Service and IIS_IUSRS have 'Read and Execute' and 'List folder contents' permissions.
3. In IIS Manager create a new application pool.

4. In IIS Manager, add a new web site.

5. WCF doesn't seem to work with IIS by default.  So open a command prompt as an administrator and run the following:
"%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r -y
6. Copy your release files into the directory created in step 1 above. Make sure that you have included your web.config with the endpoint definitions, your .svc files and the 'bin' directory with the compiled assemblies.

7. You should now be able to browse to the URL, in this case http://localhost:8000/wcftrial.svc
8. You may find you are getting a TypeLoad exception:
System.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
In this case, ASP.NET needs to be registered.  So open a command prompt as an administrator and navigate to this directory: C:\Windows\Microsoft.NET\Framework64\v4.0.30319, then execute this command:
aspnet_regiis.exe -iru
You should now be good to go.  So try step 7 again.

Useful references:

Comments