I have an object that has a generic IList in it that is being returned from a WCF web service method:
[DataContract(Name = "PageableList_Of_{0}")]
public class PageableResults<T>
{
[DataMember]
public IList<T> Items { get; set; }
[DataMember]
public int TotalRows { get; set; }
}
[OperationContract]
PageableResults<ContentItem> ListCI();
When I call this method on the service it executes the entire method fine, but at the very end it throws a System.ExecutionEngineException without an InnerException. I’ve tried returning a concrete List<> object and that seems to work, but unfortunately I need to find a workaround to return an IList. Are there any attributes I need to put in to solve this?
You’ll have to add KnownTypes attribute on the class definition above your class definition for each usage of T. Like this:
Alternatively you can define your own collection class, that has a TotalRows property, like this:
Where EntityCollectionWorkaround is defined here:
http://borismod.blogspot.com/2009/06/v2-wcf-collectiondatacontract-and.html