From: sloan on
Check my more recent blog entry about WCF interface development:

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!158.entry



<zackary.evans(a)gmail.com> wrote in message
news:1192722931.072023.81580(a)v23g2000prn.googlegroups.com...
>I am attempting to serialize a Dictionary<string, string> type in a
> WCF data contract. But when i create a service reference to my
> contact, the type instead comes out as
> ArrayOfKeyValueOfstringstringKeyValueOfstringstring[]. How do I fix
> this? I am creating the service reference in VS2005 using the WCF
> extensions. My WCF host is a simple webservice project. I do not have
> any problems creating simple datatypes, or even DataSet in this
> manner. Please help.
>
> My contract:
>
> [DataContract]
> public class MileageActivity
> {
> private Dictionary<string, string> mileageActivityPeriods;
>
> [DataMember]
> public Dictionary<string, string> MileageActivityPeriods
> {
> get { return mileageActivityPeriods; }
> set { mileageActivityPeriods = value; }
> }
> }
>
> [MessageContract]
> public class MileageActivityPeriodResponse
> {
> private MileageActivity mileageActivity;
>
> [MessageBodyMember]
> public MileageActivity MileageActivity
> {
> get { return mileageActivity; }
> set { mileageActivity = value; }
> }
> }
>
> Comes out in the Service Reference Proxy as:
>
> [System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil",
> "3.0.4506.30")]
> [System.SerializableAttribute()]
> [System.Diagnostics.DebuggerStepThroughAttribute()]
> [System.ComponentModel.DesignerCategoryAttribute("code")]
> [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://
> schemas.datacontract.org/2004/07/Spirit.Contracts.FreeSpirit")]
> public partial class MileageActivity
> {
>
> private ArrayOfKeyValueOfstringstringKeyValueOfstringstring[]
> mileageActivityPeriodsField;
>
> /// <remarks/>
> [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true,
> Order=0)]
>
> [System.Xml.Serialization.XmlArrayItemAttribute("KeyValueOfstringstring",
> Namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays",
> IsNullable=false)]
> public ArrayOfKeyValueOfstringstringKeyValueOfstringstring[]
> MileageActivityPeriods
> {
> get
> {
> return this.mileageActivityPeriodsField;
> }
> set
> {
> this.mileageActivityPeriodsField = value;
> }
> }
> }
>