Sometimes it is required to read the WCF specific information contained in the application's configuration file.
Usually, there is no need to do that by utilizing of .NET configuration system. However, imagine scenario which should
Allow you to implement some very special kind of the endpoint. Some people could find this idea very theoretically, by believe
me it is more practical than it looks.
For example, image you need the endpoint on the client which does not have an endpoint address. Unfortunately, the WCF endpoint element requires
to specify the address, because its attribute IsRequired is set on true. The bad thing is that there is not possibility to extend the endpoint element like for example
behavior extension. In such cases you will define you custom section which will read WCF standard settings.
Next example is a custom configuration section which references the standard WCF behavior.
. . .
<serviceDebug includeExceptionDetailInFaults="False" />
<myBehavior . . .>
. . .
Following code snippet shows how to read elements and properties of the given configuration.
ServiceModelSectionGroup serviceModelGroup =
if (serviceModelGroup != null)
Properties["endpointBehaviors"] != null)
EndpointBehaviorElementCollection bhvs = cfg.GetSectionGroup
foreach (EndpointBehaviorElement behavior in bhvs)
if (behavior.Name == SomeBehavior")
One full .NET 2.0 configuration example example can be downloaded here. Another intersting example about development
of custo sections and elements can be found here. Hope this help you to more understand the powerfull,but not very documented configuration system.
Feb 07 2007, 11:32 PM