7.1. Configless WCF

One of the most frustrating aspects of WCF for me was the massive amount of configuration needed—it always seemed to be much harder to configure than it should be, especially when compared with the simplicity of creating an ASMX services. With great flexibility and power comes a great big XML configuration file.

WCF4 allows you to create a service with no configuration file at all in just a few lines of code. Let's do this now:

  1. Create a new WCF Service Library project called Chapter7.ConfiglessService.

  2. Add a console application to the solution called Chapter7.ConfiglessHost.

  3. In Chapter7.ConfiglessHost, add a reference to Chapter7.ConfiglessService and the System.ServiceModel assembly.

  4. In Chapter7.ConfiglessHost Program.cs, add ...

Get Introducing .NET 4.0: with Visual Studio 2010 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.