Windows Vista Beta | WinVistaBeta.com - Message | WCF converts List<string> to string[]

July 18, 2008  
Subject: WCF converts List<string> to string[]
Group: microsoft.public.windows.developer.winfx.sdk,microsoft.public.windows.developer.winfx.general
Date: 10/30/2006 8:47:02 PM
From: "John" [Email Address Protection]

I'm having a problem passing List<T> from a service. I don't know if the
problem is at the service or the client. For some reason a List is getting
converted to an array. Here are the details:

I have a simple type called SimpleType that contains a List:

[DataContract]
public class SimpleType
{
[DataMember]
public List<string> Strings
{
get { return strings; }
set { strings = value; }
}
private List<string> strings;
}

The service code is equally simple:

public SimpleType GetSimpleType()
{
return new SimpleType();
}

The client creates the following code for SimpleType's List:

[System.Runtime.Serialization.DataMemberAttribute()]
public string[] Strings
{
get
{
return this.StringsField;
}
set
{
this.StringsField = value;
}
}

Is there something I need to do to have a List created at the client rather
than an array? Is there a property I forgot to set somewhere?

Thanks,
John



Back