Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I wrote a WCF service that declairs a class in it, One of the data members of the class is a List<sting>.

In a Silverlight application, I call a service function that returns an object of that class.

For some reason, I get the object with all the data members but the List<string> is null.

Could any one help?

My service looks like this:
C#
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        Equation Resolve(Equation equation);
    }
    
    public class Service1 : IService1
    {
        public Equation Resolve(Equation equation)
        {
            Equation e = new Equation();
            e.ResultsList =getData();
            return e;
        }
}

The class looks like this:
C#
[DataContract]
public class Equation
{
     public double C { get; set; }
     [DataMember]
      public NumOfResults numOfResults { get; set; }
     [DataMember]
    public ResultType resultType { get; set; }
     [DataMember]
     public List<string> ResultsList{ get; set; }

 }

In the silverlight i have a function:
C#
private void btnGetResult2_Click(object sender, RoutedEventArgs e)
       {
           svc.ResolveCompleted += new  EventHandler<ServiceReference.ResolveCompletedEventArgs>(svc_ResolveCompleted);
           svc.ResolveAsync(equation1);
       }
      void svc_ResolveCompleted(object sender, ServiceReference.ResolveCompletedEventArgs e)
       {
         Equation equ=e.Result;
         List<string> res=equ.ResultList;// for some reason allways null!!
       }
Posted
Updated 10-Dec-11 19:00pm
v2

1 solution

Is there ResultList too large? You might want to play around with the maxbuffersize attribute[^].
I don't see any other problem with this code. Try to check if there is a return value in getData() in your service.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900