I am trying configure a WCF endpoint to use a custom endpoint behavior extension but I keep running into this error message:
An error occurred creating the configuration section handler for system.serviceModel/behaviors: Extension element 'endpointMessageInspector' cannot be added to this element. Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions. Parameter name: element
My endpoint config looks like this:
<endpoint address="" binding="webHttpBinding" contract="Services.IGraphService"
behaviorConfiguration="corsMessageInspection"
bindingConfiguration="LargeMessageBinding"
bindingNamespace="http://some.domain.org">
</endpoint>
EndpointBehaviors:
<behavior name="corsMessageInspection">
<endpointMessageInspector />
</behavior>
BehaviorExtensions:
<behaviorExtensions>
<add name="endpointMessageInspector" type="Services.Cors.CorsEndPointExtensionElement, Services, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
I have read some other threads that say the type attribute vale of the behaviorExtension has to be exactly the same as the typeof the assembly for which the extension belongs. I keep checking and I cannot find a problem with this configuration.
Can someone tell me what I'm doing wrong?
It would seem that the name of my assembly "Services" might have been the problem. I finally attempted to edit the configuration file using the WCF Service Configuration Editor. It could not open the config complaining that the namespace "Services.Cors.CorsEndPointExtensionElement did not exist when, indeed, it did.
I ended up moving my WCF behavior extension code into its own assembly, with a different namespace. This fixed the issue. I haven't tested whether or the name, "Services" was a conflict or not.
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