Click here to Skip to main content
15,867,453 members
Articles / WCF

What’s New in WCF 4.5? Configuration Validations

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
9 Feb 2012CPOL3 min read 13.3K   2  
Configuration validations in WCF 4.5

This is the fourth post in the WCF 4.5 series, and a direct addition to the previous post, since I neglected to mention something important about editing configuration files in WCF 4.5 and Visual Studio 11 – validations during editing and compilation.

Previous Posts

  1. What’s new in WCF 4.5? Let’s start with WCF configuration
  2. What’s new in WCF 4.5? A single WSDL file
  3. What’s new in WCF 4.5? Configuration tooltips and intellisense in config files

In my last post, I mentioned the problems we face when manually configuring services in the configuration file (app.config / web.config), mainly when dealing with service names.

In WCF 3.5, there was less problem using wrong service names, since there had to be at least one endpoint for each service, and if you have used the wrong service name in the configuration – you would have gotten an exception.

But with WCF 4, the rules have changed because of default endpoints – you haven’t configured any service endpoint? No worries, the service host will create some for you, according to your base address. This causes many people to not notice they have used the wrong service name, and thus get endpoints that often aren’t the ones they wanted, for example getting a default basicHttp endpoint instead of a netTcp endpoint that was declared in the configuration.

In comes WCF 4.5, or to be more exact Visual Studio 11, with its configuration intellisense, and as we’ve seen in the previous post, the intellisense gives us the option to select which service class to configure. Another good thing that comes out of it is warnings – if you use the wrong service name in the <service> element, you will get a compilation warning, as shown in the following screenshot:

image

The validations also apply to other parts of the configuration, such as contract names, binding names, and binding / behavior configuration names, as can be seen in the following screenshot (I added the highlights).

image

Although useful, the last type of validations is less crucial, since usually if you got the name of the service correctly, and misspelled one of the other names, that would cause an exception while opening the service host, so at least you’ll know about it, unlike using the wrong service name.

So to conclude – Intellisense, cool! Tooltips, cool! Validations, also cool! WCF 4.5 – very cool!

Stay tuned for more posts about the new features of WCF 4.5. You can also follow me on Twitter (@IdoFlatow) to get updates as soon as new posts are published.

The RTM of .NET 4.5 is still to come, and I assume many of you are still adjusting to WCF 4. If you want to learn more about the new features of WCF 4, come to my session at Visual Studio Live! 2011 in Redmond (October 17-21).

Also, if you are an MCT and reside in the US, come hear my session about WCF 4 at the MCT 2011 North-America Summit that will be held in San-Francisco (October 19-21).

Image 3

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Sela Group
Israel Israel
Web developer since 1997. I'm a senior architect at Sela Group in Israel. I'm a consultant, trainer (Microsoft MCT), and a speaker in conferences worldwide.
My main fields are WCF, ASP.NET, Windows Azure, IIS, Entity Framework, and Silverlight.

Comments and Discussions

 
-- There are no messages in this forum --