title: WCF Read data issue from service
body: <p>I am tying to get the generic List of user <code>List&lt;User&gt;</code> object from my web service to my web application. probably this is common issue. i searched a lot but got different remedies with each link. so finally i decide to ask to chaps over here... anyways</p>
  
  <p>I am using console application for fetching the data from my hosted wcf web service. where as my WCf web service having the Entity framework 4.1. am using objects from its model class. when i tried to add service reference to my web application , it typically generates the proxy in web app. i am able to post data means i could create user. but while <code>getusers</code> which is returning List , getting following exceptions...:</p>
  
  <blockquote>
    <p>Exception:<br>
    An error occurred while receiving the HTTP response to
    <a href="http://myserver/AdminService/MyAdminService.svc" rel="nofollow">http://myserver/AdminService/MyAdminService.svc</a>. 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.</p>
    
    <p>Inner Exception is :<br>
    The underlying connection was closed: An unexpected error occurred
    on a receive</p>
    
    <p>and inner-inner exception is :  Unable to read data from the
    transport connection: An existing connection was forcibly closed by
    the remote host.</p>
    
    <p>with message : An existing connection was forcibly closed by the
    remote host<br>
    Error Code  :10054</p>
    
    <p>Where as Event log saying :<br>
    A message was not logged.<br>
    Exception: System.ServiceModel.CommunicationException: There was
    an error while trying to serialize parameter
    <a href="http://tempuri.org/:getUsersResult" rel="nofollow">http://tempuri.org/:getUsersResult</a>. The InnerException message was
    'Type
    'System.Data.Entity.DynamicProxies.User_00DEC686D7E21DB0D84B595F647A03FFB4943938F76E8C3DBBE0F77F8BC29A1D'
    with data contract name
    'User_00DEC686D7E21DB0D84B595F647A03FFB4943938F76E8C3DBBE0F77F8BC29A1D:http://schemas.datacontract.org/2004/07/System.Data.Entity.DynamicProxies'
    is not expected. Consider using a DataContractResolver or add any
    types not known statically to the list of known types - for example,
    by using the KnownTypeAttribute attribute or by adding them to the
    list of known types passed to DataContractSerializer.'.  Please see
    InnerException for more details. --->
    System.Runtime.Serialization.SerializationException: Type
    'System.Data.Entity.DynamicProxies.User_00DEC686D7E21DB0D84B595F647A03FFB4943938F76E8C3DBBE0F77F8BC29A1D'
    with data contract name
    'User_00DEC686D7E21DB0D84B595F647A03FFB4943938F76E8C3DBBE0F77F8BC29A1D:http://schemas.datacontract.org/2004/07/System.Data.Entity.DynamicProxies'
    is not expected. Consider using a DataContractResolver or add any
    types not known statically to the list of known types - for example,
    by using the KnownTypeAttribute attribute or by adding them to the
    list of known types passed to DataContractSerializer.
           at
    System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract
    dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean
    verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type
    declaredType)
           at
    System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiType(XmlWriterDelegator
    xmlWriter, Object obj, RuntimeTypeHandle objectTypeHandle, Type
    objectType, Int32 declaredTypeID, RuntimeTypeHandle
    declaredTypeHandle, Type declaredType)
           at
    System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator
    xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType,
    Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
           at
    System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerializeReference(XmlWriterDelegator
    xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType,
    Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
           at WriteArrayOfUserToXml(XmlWriterDelegator , Object ,
    XmlObjectSerializerWriteContext , CollectionDataContract )
           at
    System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator
    xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
           at
    System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator
    writer, Object graph, DataContractResolver dataContractResolver)
           at
    System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator
    writer, Object graph, DataContractResolver dataContractResolver)
           at
    System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator
    writer, Object graph, DataContractResolver dataContractResolver)
           at
    System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter
    writer, Object graph)
           at
    System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameterPart(XmlDictionaryWriter
    writer, PartInfo part, Object graph)
           --- End of inner exception stack trace ---
           at
    System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameterPart(XmlDictionaryWriter
    writer, PartInfo part, Object graph)
           at
    System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameter(XmlDictionaryWriter
    writer, PartInfo part, Object graph)
           at
    System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter
    writer, MessageVersion version, String action, MessageDescription
    messageDescription, Object returnValue, Object[] parameters, Boolean
    isRequest)
           at
    System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter
    writer)
           at
    System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter
    writer)
           at
    System.ServiceModel.Channels.Message.ToString(XmlDictionaryWriter
    writer)
           at
    System.ServiceModel.Diagnostics.MessageLogTraceRecord.WriteTo(XmlWriter
    writer)
           at
    System.ServiceModel.Diagnostics.MessageLogger.LogInternal(MessageLogTraceRecord
    record)
           at
    System.ServiceModel.Diagnostics.MessageLogger.LogMessageImpl(Message&amp;
    message, XmlReader reader, MessageLoggingSource source)
           at
    System.ServiceModel.Diagnostics.MessageLogger.LogMessage(Message&amp;
    message, XmlReader reader, MessageLoggingSource source)
         Process Name: w3wp
         Process ID: 5928</p>
  </blockquote>
  
  <p>What should be this issue. me and team searching for this since 3 days. but unfortunately not overcome so far... </p>
  
  <p>I tried lot of stuffs like add serializable attribute, endpoint modifications ... i can not recollect all :) ... probably you may give us right directions...</p>