I’m trying to extend WCF with a custom binding which has required that I replace message formatting, encoding and security elements within the WCF stack. To facilitate ease-of-use with this binding, I’d like to make it configurable from a configuration file in the same way as the built-in bindings (i.e. a named element, not customBinding).
The WCF standard bindings all inherit from StandardBindingElement, which in turn implements IBindingConfigurationElement. If I implement this interface or inherit from the class, how can I make the configuration element available to the WCF configuration system?
I did some digging and found the
bindingExtensionselement on MSDN. Although the documentation there indicates that you can add bindings this way, I had a peek at my machine.config file and found the following 3.5 bindings registered there:These classes function as collections of binding elements, inheriting from the odd
StandardBindingCollectionElement<TStandardBinding, TBindingConfiguration>class. This looks to be the correct class to inherit from and create an associatedStandardBindingElementfrom.The collection is registered using the syntax listed above and should then function exactly the same as built-in WCF bindings.