title: Calling a get function of wcf throws CommunicationException
body: <p>I've two projects. One having wcf service and database. Other used for calling these functions. If I call a function of webservice which adds something to the database it works fine. But when I call a function which retrieves something from database. I get CommunicationException. The function I'm calling in WebService.svc.cs is:</p>
  
  <pre><code>public List&lt;Artist&gt; GetAllArtists()
          {
              Database1Entities db = new Database1Entities();
              return (db.Artists).ToList();
          }
  </code></pre>
  
  <p>And I'm calling it like this</p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
      {
          ServiceReference2.WebServiceClient o = new ServiceReference2.WebServiceClient();
          Artist [] artists = o.GetAllArtists(); //Exception arises here
          string str = "";
          foreach (Artist artist in artists){
              str += artist.ArtistID + " ";
          }
          Response.Write(str);
          gv.DataSource = artists;
          gv.DataBind();
      }
  </code></pre>
  
  <p>Exception:</p>
  
  <blockquote>
    <p>System.ServiceModel.CommunicationException was unhandled by user code
    HResult=-2146233087 Message=An error occurred while receiving the HTTP
    response to <a href="http://localhost:23060/WebService.svc" rel="nofollow">http://localhost:23060/WebService.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. Source=mscorlib StackTrace: Server stack trace: at
    System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException
    webException, HttpWebRequest request, HttpAbortReason abortReason) at
    System.ServiceModel.Channels.HttpChannelFactory1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan
    timeout)
             at System.ServiceModel.Channels.RequestChannel.Request(Message message,
    TimeSpan timeout)
             at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message<br>
    message, TimeSpan timeout)
             at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
    Object[] outs, TimeSpan timeout)
             at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
    methodCall, ProxyOperationRuntime operation)
             at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage<br>
    message)
          Exception rethrown at [0]: 
             at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
    reqMsg, IMessage retMsg)
             at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp;<br>
    msgData, Int32 type)
             at WebLab6AlbumManagementSystemClient.ServiceReference2.IWebService.GetAllArtists()
             at WebLab6AlbumManagementSystemClient.ServiceReference2.WebServiceClient.GetAllArtists()
    in c:\Users\Muhammad Rehan\Documents\Visual Studio<br>
    2013\Projects\WebLab6AlbumManagementSystemClient\Service<br>
    References\ServiceReference2\Reference.cs:line 567
             at WebLab6AlbumManagementSystemClient.ViewAllArtists.Page_Load(Object<br>
    sender, EventArgs e) in c:\Users\Muhammad Rehan\Documents\Visual<br>
    Studio<br>
    2013\Projects\WebLab6AlbumManagementSystemClient\ViewAllArtists.aspx.cs:line
    16
             at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,
    EventArgs e)
             at System.Web.UI.Control.OnLoad(EventArgs e)
             at System.Web.UI.Control.LoadRecursive()
             at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)</p>
    
    <p>InnerException: System.Net.WebException
             HResult=-2146233079
             Message=The underlying connection was closed: An unexpected error occurred on a receive.
             Source=System
             StackTrace:
                  at System.Net.HttpWebRequest.GetResponse()
                  at System.ServiceModel.Channels.HttpChannelFactory1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan
    timeout) InnerException: System.IO.IOException HResult=-2146232800
    Message=Unable to read data from the transport connection: An existing
    connection was forcibly closed by the remote host. Source=System
    StackTrace: at System.Net.Sockets.NetworkStream.Read(Byte[] buffer,
    Int32 offset, Int32 size) at System.Net.PooledStream.Read(Byte[]
    buffer, Int32 offset, Int32 size) at
    System.Net.Connection.SyncRead(HttpWebRequest request, Boolean
    userRetrievedStream, Boolean probeRead) InnerException:
    System.Net.Sockets.SocketException HResult=-2147467259 Message=An
    existing connection was forcibly closed by the remote host
    Source=System ErrorCode=10054 NativeErrorCode=10054 StackTrace: at
    System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32
    size, SocketFlags socketFlags) at
    System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
    Int32 size) InnerException:</p>
  </blockquote>