I'm adding a custom endpoint behaviour to my WCF service with a class extended from BehaviorExtensionElement to initialise it. In my web.config, I add the following to register the behaviour extension:
<system.serviceModel>
    <services>
      <service name="Service.MyService">
        <endpoint address=""
                  behaviorConfiguration="endpointBehavior"
                  binding="basicHttpBinding"
                  contract="Contracts.IMyService"/>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="endpointBehavior">
          <logBehavior />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <extensions>
      <behaviorExtensions>
        <add name="logBehavior"
             type="MyNamespace.MyBehaviorExtensionElement, MyAssembly, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null" />
      </behaviorExtensions>
    </extensions>
</system.serviceModel>
This works absolutely fine, but I have to specify the version of the assembly to get it to load. If I change the assembly reference to just MyNamespace.MyBehaviorExtensionElement, MyAssembly without the version/culture/token then the service fails to launch with the error:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: An error occurred creating the configuration section handler for system.serviceModel/behaviors: Extension element 'logBehavior' cannot be added to this element. Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions. Parameter name: element
The final portion of my assembly version will change frequently as part of my build process. How can I avoid having to keep updating the web.config with the new version number every time the build version increments (which could be hundreds of times)? 
I think the restriction on fully specified class names has been removed in .net 4 or above. Have you tried:
  <behaviorExtensions>
     <add name="logBehavior"
         type="MyNamespace.MyBehaviorExtensionElement, MyAssembly" />
  </behaviorExtensions>
I might be wrong!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With