title: WCF- "The underlying connection was closed: The connection was closed unexpectedly"
body: <p>I'm recieving that wonderfuly ambiguous error message when using one of my webmethods on my WCF webservice. As that error message doesn't provide any explanation whatsoever allow me to post my theory.</p>
  
  <p>I believe it may have something to do with the return type I'm using</p>
  
  <p>I have a Types DLL which is refrenced in both the webservice and the client. In this DLL is the base class ExceptionMessages. There is a child of this class called DrawingExcepions.</p>
  
  <p>Here is some code:</p>
  
  <pre><code>public class ExceptionMessages
  {
      public object[] ReturnValue { get; set; }
  }
  
  public class DrawingExceptions : ExceptionMessages
  {
      private List&lt;DrawingException&gt; des = new List&lt;DrawingException&gt;();
  }
  
  public class DrawingException
  {
      public Exception ExceptionMsg { get; set; }
      public List&lt;object&gt; Errors { get; set; }
  }
  </code></pre>
  
  <p>The using code:</p>
  
  <pre><code>    [OperationContract]
      ExceptionMessages createNewBom(Bom bom, DrawingFiles dfs);
  
      public ExceptionMessages createNewBOM(Bom bom, DrawingFiles dfs)
      {
              return insertAssembly(bom, dfs);
      }
  
      public DrawingExceptions insertAssembly(Bom bom, DrawingFiles dfs)
      {
          DrawingExceptions des = new DrawingExceptions();
  
          foreach (DrawingFile d in dfs.drawingFiles)
          {
              DrawingException temp = insertNewDrawing(bom, d);
              if (temp != null)
                  des.addDrawingException(temp);
  
              if (d.Child != null)
                  des.addDrawingException(insertAssembly(bom, d.Child));
          }
  
          return des;
      }
  </code></pre>
  
  <p>Returns to:</p>
  
  <pre><code>    ExceptionMessages ems = client.createNewBom(bom, currentDFS);
  
      if (ems is DrawingExceptions) { }
  </code></pre>
  
  <p>Basically the return type from the webmethod is ExceptionMessages however I would usually be sending the child class back instead.</p>
  
  <p>My only idea is that it's the child that's causing the error but as far as I've read, this should have no effect. Has anyone got any ideas what could be going wrong here?</p>
  
  <p>If any more info is required, just ask :)</p>
  
  <p>Thanks.</p>