WCF comes with a very handy configuration language that allows you to define bindings, end point properties and the like. Doing the same in code is a) tedious, b) inflexible: any minuscule change would require recompilation and redeployment.
The trouble is, the configuration information is read from the .NET configuration file, which is unconditionally set to
calling_executable.exe.config, at least for the primary app domain. This is true even if the calling executable is not a .NET application.
This inflexible rule stands in a way of self-contained libraries that use WCF. It is not possible to define WCF configuration on a per library basis, it must be done at the application level. Not only we have a leaking abstraction here, this abstraction may leak into very interesting places. E.g. if you are writing a COM+ component, the configuration file it will use suddenly depends on whether it is in-proc or out-of-proc, and all out-of-proc components may as well end up reading
Modular application that load plugins dynamically (along the lines of CAB) face even bigger problem. It is not possible to know in advance what WCF settings will be used by a plug-in, so this information cannot be placed into the application config.
Reading a different configuration file should have been easy, but it is not. WCF is really hardwired to
calling_exe.exe.config. Some redirection is possible, but it is quite verbose and complicated (see “Loading the WCF configuration from different files on the client side“).
This is only one consequence of Microsoft’s decision to hardwire the configuration to a specific file. In the Java world this decision would probably be unthinkable. Almost everything in Java can be substituted to a different implementation. If it’s not an interface, it’s a system property. .NET, however, pursues a different philosophy (see “Is .NET Really a Java Clone?“).
In many cases it is fine, but the decision to hardwire the configuration path is unfortunate and it keeps biting us. Mr. Gates, thou shalt not hard code!