So, I spent a few hours spinning my wheels trying to figure out why I’ve been getting the following exception:
[SocketException (0x2746): An existing connection was forcibly closed by the remote host] [IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.] [WebException: The underlying connection was closed: An unexpected error occurred on a receive.] [CommunicationException: An error occurred while receiving the HTTP response to http://myservice.mydomain.dk/MyService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.]
Of the many reasons why you might see this exception, one is that the return value of a WCF service method cannot be of type System.Collections.IEnumerable or System.Collections.Generic.IEnumerable
The solution of course is to change the service method definition to return an array.



Nizar,
Even it is not possible to return IList from WCF.
Yea, because IList inherits from IEnumerable.
IEnumerable CAN be returned from a WCF service method.
Did you use VS to generate the proxies? If so, take a look at the generated code and you’ll notice that VS converted the IEnumerables to arrays.
@Nizar
Your title states that WCF return values cannot be of type IEnumerable – which they can be. Client proxy classes not being able to consume an IEnumerable is a different issue.
Thanks for pointing that out! I’ll consider renaming the title.
@JW: Title renamed and content edited. Thanks for your suggestion!