3
votes

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?

2
CorsEndPointExtensionElement needs to inherit BehaviorExtensionElement class. The overload CreateBehaviour() method in CorsEndPointExtensionElement should return a new behavior which implements IEndpoinBehavior. - Rajesh
Would be easy if you can show your implementation of creating a custom behaviour element and the message inspector - Rajesh
@Rajesh Thanks.. my extension does inherit from BehaviorExtensionElement. The problem, I believe, is actually the name of the assembly I was trying to register. - Nick

2 Answers

1
votes

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.

0
votes

is this correct version? --> Version=0.0.0.0