The simple case where my OperationContract
implementation is like:
public List<Directory> GetDirectories(bool includeFiles)
{
if (includeFiles)
{
return this.db.Directories.Include(e => e.Files).ToList();
}
else
{
return this.db.Directories.ToList();
}
}
where GetDirectories(false);
works perfectly ok and GetDirectories(true);
throws a CommunicationObjectFaultedException
with message:
The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
Obviously my File
entities have reference to Directory
entities, and the Directory
entities have a list of files. First I thought this would be the typical cyclic reference trap but I get no signs of it in the exception message. Any ideas on this problem?