Saturday, May 19, 2012

Proxyless WCF: Sample Source Code

Now that the blog is being hosted on a real web site, I'm finally getting around to uploading sample code. I've re-uploaded my caching IStream wrapper, and have uploaded the sample solution from the Proxyless WCF Series.

You can find the entire solution here.

Some notes about this solution that will generally apply to any other projects I upload:

The projects are made for Visual Studio 11, but should work fine under Visual Studio 2010. For the time being they all still use .NET Framework v4.0 and C# 4.0, unless otherwise noted. The database projects require you to install the SQL Server Data Tools extension for VS2010. They also assume you have a local SQL Express instance named SQLEXPRESS; if not, you'll need to fix up the connection strings and deployment options.

The web site and service host projects are configured to use IIS Express. Generally speaking, if you have IIS Express installed, just opening the project in Studio will configure everything properly. However, IIS Express can sometimes get confused when you first open a project that has an https base URL (such as the Proxyless WCF service.)

In these cases, Visual Studio will likely try to set up a standard http binding, but using the https port. This doesn't actually work, and Studio usually complains that it didn't have sufficient access to configure the site. In reality, you just need to manually edit the bindings to add both secure and non-secure ports separately. Find the applicationhost.config file (in your Documents\IISExpress folder), and locate the <site> element for the project. (If you've tried to open the project more than once, you may have several copies; just delete all but the first.) Then edit the bindings to specify the correct ports for both protocols. For example, the Proxyless WCF service should have the following bindings set up:

  <binding protocol="http" bindingInformation="*:6067:localhost" />
  <binding protocol="https" bindingInformation="*:44302:localhost" />

Make sure you set up a non-secure binding, even if you never use it; this will prevent Studio from getting confused the next time you open the project.