Monday, February 7, 2011

Myth: WCF Configuration is hard , Result: False

Okay. If you do it manually by editing the app.config / web.config file. Then yes. It can be.
But there is a better graphical way to do this using the Microsoft Service Configuration Editor (SvcConfigEditor.exe). Its use is recommended to avoid annoying spelling mistake errors :)

It is available right from visual studio when you right click app.config or web.config file AFTER you have started it once i.e. by default if you right click web.config or app.config you can't see the option "Edit WCF Configuration" :
Option for "Edit WCF Configuration" is not available by default
You need to start the Service Editor at least once for the option to become available. You can start the service editor from Tools -- WCF Service Configuration Editor :
After the Editor opens you can simply close it:
Simply close this window (or you can open a .config file manually)
Now when you right click web.config or app.config you will see the option "Edit WCF Configuration":
And the web.config / app.config file will be opened in the Microsoft Service Configuration Editor :
Click to enlarge :)
Note that you can even edit the Diagnostics section of System.ServiceModel. Awesomeness :)

A Note about correlation between imperative configuration in code vs. configuration in .config:
Items in config as attributes map to properties in code.
Items as inner xml elements map to properties that are complex types in .net (i.e WCF classes rather than simple enums / ints / TimeSpans etc).
A very useful (albeit fundamental / obvious) observation.