Tuesday, November 17, 2009

Configure WCF to run on Windows 7

When you’ve installed Windows 7 and installed all the appropriate IIS features, WCF will still not be available on your box by default. I’ve had this little note to myself laying around somewhere on the file system, but I just keep forgetting where it is every time I need it. So I’ll put it up here, just to make the search a bit easier :)

Open up the command prompt in Administrator mode, and run the following command;

c:\…>"%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r

This will map the svc file type to aspnet_isapi.dll  and will make IIS recognize WCF services and startup the ServiceHost for you. In other words; the svc MIME type will be registered with IIS. The parameters on the end is;

-r: Re-registers this version of WCF and updates scriptmaps at the IIS metabase root and for all scriptmaps under the root. Existing scriptmaps are upgraded to this version regardless of the original versions.

(copied from the official docs on the “ServiceModel Registration Tool”)


If you’ll be running integration tests against your services and the test will do WCF self hosting (instead of IIS), you also need to authorize the urls that your self-hosting service will be using;

c:\…>netsh http add urlacl url=http://+:[port]/ user="[windows user name]"

As for the ServiceModelReg command, this one will also need administrator privileges on your command prompt. Replace the [windows user name] with the account you’ll be running the test under. Usually this will be the account you’re logged in with, e.g. “domain\user”. The [port] parameter will be the port number you’ve configured on your WCF endpoint (typically 8000 for testing).


And just to be sure; restart the IIS after you’ve run these commands;