C# – WCF -An error occurred while receiving the HTTP response

I try to get list from service like this:

   static void Main(string[] args)
      MyClient proxy = new MyClient();
      List<X> l = proxy.Func(1).ToList();

X is class from DLL of entity framework project.

My function in service look like this:

    public List<X> Func(int NUM)
        ProjectContext MyContext = new ProjectContext();
        s = MyContext.X.ToList();
        return s;


My context define like this:

public class ProjectContext : DbContext

    public ProjectContext ()
        : base("name=ApplicationServices")
        this.Configuration.LazyLoadingEnabled = false;

    public DbSet<XX> X{ get; set; }


I get error:

An error occurred while receiving the HTTP response to XXX. 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.

Solution to answer:

The exception could be due to cyclic reference. Mark the navigational properties in your entities with IgnoreDataMember attribute so they don't take part in serialization.