views:

32

answers:

1

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.

A: 

I don't have an official answer, but I've noticed that in the RTW version of SL 3.0, the automatic proxy generation sometimes barfs on me, and mucking up the passing of arrays/lists/generic collections is part of what happens. My workaround -- which admittedly sucks -- is kinda odd: I right-click the service reference, choose "configure service reference", select "re-use types in referenced assemblies", and then muck about with which types/assemblies should be re-used. Eventually it seems to work.

If that doesn't work, I restart Visual Studio, and the automatic proxy generation often works at that point.

Hope this helps at least point you in the right direction.

Ken Smith