I've sent various other objects over my WCF service through lists without any issues however when I try to send this specific object (in a list) I get, sort of a timeout error.
The trace identifier is:
TraceIdentifier http://msdn.microsoft.com/da-DK/library/System.ServiceModel.Diagnostics.TraceTruncatedQuotaExceeded.aspx
The strange thing is: I got another method that returns the object exclusively (not in a list) and it works fine.
Furthermore when debugging I've found out that the method (on the service side) returns the list just fine however it's the client that apparently fails receiving it.
Here's the method that calls the service (it fails on the line declaring "revs"):
public void GetReviewsInModule()
{
using (var db = new RentItServiceClient())
{
var revs = db.GetReviewsInModule(1);
}
}
Here's the method that actually returns the objectas a list (debugged it and it returns it fine):
public List<ReviewModule> GetReviewsInModule(int id)
{
using (Context con = new Context())
{
con.Configuration.ProxyCreationEnabled = false;
var mod = con.Modules.Find(id);
if (mod == null)
throw new WebServiceValidationException("Object does not exist");
List<ReviewModule> revs = con.ModuleReviews.Include("User").Where(r => r.Module.Id == id).ToList();
return revs;
}
}
Also, the object in the list are hardly of any size so please don't tell me to up the sending/receiving limits/timeouts.
It's hard to give you an answer based just on the code you've posted, since it's not possible to replicate the problem just from those few snippets. (You'd need to post the full definition of ReviewModule, your service contract, etc, for that).
Therefore this is just a guess, but I've been caught out a few times when using WCF and MVC Web Api to set up RESTful web services when I've employed a Using block within endpoints. Although Using is a valuable construct within C#, I find that when you have one that's defined within a method that represents an endpoint that is ultimately called by code you don't control, then the IDisposable interface that the Using block relies on to work gets messed up. That is, you're defining an object within your method (in this case an object of type Context named "con"), and it's only later on that the WCF framework you're relying upon tries to access the object created within your endpoint. By the time the WCF framework does its job, the Dispose() method on your Context object is likely to already have been called by your code, meaning that the WCF framework can't access it in the way that it needs to in order to be able to return the data your service is intended to serve up. This may be the case even if your method works in isolation when you unit test it from code that is completely under your control.
To see if that's the problem in your case, try removing the Using block in your "GetReviewsInModule" method / service endpoint, like so:
public List<ReviewModule> GetReviewsInModule(int id)
{
Context con = new Context();
con.Configuration.ProxyCreationEnabled = false;
var mod = con.Modules.Find(id);
if (mod == null) throw new WebServiceValidationException("Object does not exist");
List<ReviewModule> revs = con.ModuleReviews.Include("User").Where(r => r.Module.Id == id).ToList();
return revs;
}
If that causes your endpoint to start working as expected, you can worry about how you're going to manage object disposal and avoid memory leaks as a separate issue.
It really depends on how many elements are in the result list, too, not only on the sizes of the individual elements. There are some configuration elements you can play with:
maxReceivedMessageSize
maxBufferSize
maxBufferPoolSize
maxArrayLength
maxStringContentLength
Another solution would be to switch to streamed WCF services. Please note that you can not mix streamed and buffered operations - I sometimes actually create two WCF services, one for streamed operations and one for buffered operations.