FirstOrDefault on Behaviors collection not found RRS feed

  • Question

  • Hello.

    I posted this in the VS Languages forum and the moderator advised me to move it here.

    I'm searching for a behavior in my .Net 4.5 WCF service's endpoint using the following code. Sometimes it works, some times I get the error "Exception: System.MissingMemberException: Public member 'FirstOrDefault' on type 'KeyedByTypeCollection(Of IEndpointBehavior)' not found."

    Here's my code:

    var theBehavior = myService.Endpoint.Behaviors.FirstOrDefault(b => b is myBehavior) as myBehavior;

    The variable "myService" is not null.

    Any thoughts?

    Thanks in advance,


    Monday, January 27, 2014 1:04 PM


  • Hi,

    Please try to check if the following helps:

    foreach (var endpoint in serviceHost.Description.Endpoints)
                      IEndpointBehavior exisitingBehavior = endpoint.Behaviors.FirstOrDefault(b => b is myBehavior) as myBehavior;


    Also please try to debug your code.

    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 28, 2014 5:43 AM