Tuve este error con mi extensión de comportamiento personalizado que quería agregar como comportamiento de punto final. Entonces, edité el esquema utilizado en Visual Studio 2017 para eliminar la advertencia en mi archivo web.config.Es la misma advertencia que recibió:
El elemento 'comportamiento' tiene un elemento secundario no válido 'CustomSecurity'. Lista de posibles elementos esperados: 'clientVia, callbackDebug, callbackTimeouts, clear, clientCredentials, transactedBatching, dataContractSerializer, dispatcherSynchronization, remove, synchronousReceive, webHttp, enableWebScript, endpointDiscovery, soapProcessing'.
Mi web.config tiene: nodo XML
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="CustomSecurity"
type="FullyQualifiedPath.MyCustomBehaviorExtension, MyAssemblyName"/>
</behaviorExtensions>
</extensions>
<endpointBehaviors>
<behavior name="CustomServiceBehavior">
<CustomSecurity />
</behavior>
</endpointBehaviors>
<endpoint address="https://SomeServer/MyService.svc/soap"
behaviorConfiguration="CustomServiceBehavior" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IProject" contract="ProjectService.IProject"
name="BasicHttpBinding_IProject" />
El CustomSecurity siempre tenía la línea azul ondulada debajo de ella en Visual Studio. Aparece como una advertencia en la ventana Lista de errores. Quería deshacerme de él porque cada vez que intenté actualizar una referencia de servicio, fallaba debido a la advertencia en web.config.
Por lo tanto, para solucionarlo, necesitará editar el esquema que Visual Studio usa para validar los elementos. Entonces, abrí mi web.config, luego seleccioné XML en la barra de menú principal de Visual Studio. Luego seleccione Schemas. Obtendrás una larga lista de esquemas. Busque "DotNetConfig.xsd" como se ve a continuación.
Examine la ruta que se muestra y edite el archivo xsd. Buscar: <xs:element name="behavior" vs:help="configuration/system.serviceModel/behaviors/endpointBehaviors/behavior">
A continuación, agregue un nuevo nodo xs: element dentro del nodo xs: choice con el nombre de su extensión de comportamiento personalizado; en mi caso, CustomSecurity. Guarde el archivo y Visual Studio debe validar automáticamente contra el nuevo esquema y no debería recibir una advertencia en su web.config por más tiempo.
<xs:element name="behavior" vs:help="configuration/system.serviceModel/behaviors/endpointBehaviors/behavior">
<xs:complexType>
<xs:annotation>
<xs:documentation>The behavior element contains a collection of settings for the behavior of an endpoint.</xs:documentation>
</xs:annotation>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="CustomSecurity" vs:help="configuration/system.serviceModel/behaviors/endpointBehaviors/behavior/CustomSecurity">
<xs:complexType>
<xs:annotation>
<xs:documentation>Specifies the behavior extension class applied to the endpoint.</xs:documentation>
</xs:annotation>
<xs:anyAttribute namespace="http://schemas.microsoft.com/XML-Document-Transform" processContents="strict" />
</xs:complexType>
</xs:element>
<xs:element name="clientVia" vs:help="configuration/system.serviceModel/behaviors/endpointBehaviors/behavior/clientVia">
<xs:complexType>
<xs:annotation>
<xs:documentation>Specifies the URI for which the transport channel should be created.</xs:documentation>
</xs:annotation>
<xs:attribute name="viaUri" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>A string that specifies a URI that indicates the route a message should take.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="lockAttributes" type="xs:string" use="optional" />
<xs:attribute name="lockAllAttributesExcept" type="xs:string" use="optional" />
<xs:attribute name="lockElements" type="xs:string" use="optional" />
<xs:attribute name="lockAllElementsExcept" type="xs:string" use="optional" />
<xs:attribute name="lockItem" type="boolean_Type" use="optional" />
<xs:anyAttribute namespace="http://schemas.microsoft.com/XML-Document-Transform" processContents="strict" />
</xs:complexType>
</xs:element>
http://connect.microsoft.com/VisualStudio/feedback/details/619106/wcf-fails-to-find-custom-behaviorextensionelement-if-type-attribute-doesnt-match-exactly – nologo
posible duplicado de [Audiencia "elemento 'comportamiento' tiene elemento secundario no válido" se debe ignorar, pero se le impidió actualizar la referencia del servicio debido a ello] (http://stackoverflow.com/questions/9482091/hearing-element-behavior-has-invalid- child-element-should-be-ignored-but-pr) – McGarnagle