I've been struggling with a webservice that throws an ExecutionEngineException for the past day. I finally worked out that the Silverlight client doesn't like IEnumerable<> nor IList<> nor List<> as the return type. MyObject[] is fine though.
I managed to reproduce it in a sample solution:
Service description:
[ServiceContract]
public interface IService
{
[OperationContract]
IEnumerable<Person> SomeStuff();
}
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service : IService
{
public IEnumerable<Person> SomeStuff()
{
return new Person[] { new Person { Name = "some person", ID = 42 } };
}
}
[DataContract]
public class Person
{
[DataMember]
public string Name { get; set; }
[DataMember]
public int ID { get; set; }
}
On the client side, just create a service reference and call the service. Exception is thrown after the service returns.
Any idea on what's causing the issue would be appreciated.