From: zackary.evans on
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;
}
}
}

From: Nicholas Paldino [.NET/C# MVP] on
Zack,

How did you generate the proxy? If through VS.NET, did you set the
dictionary collection type in the service reference settings dialog? If you
did it through the svcutil utility, then did you use the /collectionType (or
/ct) flag? You need to specify what to use as a collection type in the
proxy.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp(a)spam.guard.caspershouse.com

<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;
> }
> }
> }
>


From: zackary.evans on
It was generated in VS.NET (2005) using the "Add Service Reference"
menu. I do not see a service reference settings dialog though. How do
I get there?

thanks!

Zack

On Oct 18, 12:15 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...(a)spam.guard.caspershouse.com> wrote:
> Zack,
>
> How did you generate the proxy? If through VS.NET, did you set the
> dictionary collection type in the service reference settings dialog? If you
> did it through the svcutil utility, then did you use the /collectionType (or
> /ct) flag? You need to specify what to use as a collection type in the
> proxy.
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - m...(a)spam.guard.caspershouse.com
>
> <zackary.ev...(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;
> > }
> > }
> > }


From: Nicholas Paldino [.NET/C# MVP] on
Zack,

I misspoke. The dialog for VS.NET is going to be in the 2008 version.
However, you can still use the /ct (or /collectionType) flag using the
svcutil command line app to generate the proxy, and then add that to your
project. For more details, see:

http://www.request-response.com/blog/PermaLink,guid,ff5fab81-affb-4b2b-aa67-c80bdfc86cbd.aspx


--
- Nicholas Paldino [.NET/C# MVP]
- mvp(a)spam.guard.caspershouse.com


<zackary.evans(a)gmail.com> wrote in message
news:1192727531.053875.307990(a)q5g2000prf.googlegroups.com...
> It was generated in VS.NET (2005) using the "Add Service Reference"
> menu. I do not see a service reference settings dialog though. How do
> I get there?
>
> thanks!
>
> Zack
>
> On Oct 18, 12:15 pm, "Nicholas Paldino [.NET/C# MVP]"
> <m...(a)spam.guard.caspershouse.com> wrote:
>> Zack,
>>
>> How did you generate the proxy? If through VS.NET, did you set the
>> dictionary collection type in the service reference settings dialog? If
>> you
>> did it through the svcutil utility, then did you use the /collectionType
>> (or
>> /ct) flag? You need to specify what to use as a collection type in the
>> proxy.
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - m...(a)spam.guard.caspershouse.com
>>
>> <zackary.ev...(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;
>> > }
>> > }
>> > }
>
>


From: zackary.evans on
Yeah, I actually just found that article while googling. But it doesnt
seem to work for me. I still get the same results.

here is my command:

C:\Program Files\Microsoft Visual Studio 8\VC>svcutil /
ct:System.Collections.Gen
eric.Dictionary`2 http://localhost/Blah.Service.Web/Service.svc

It generates the proxy fine, but I still get
ArrayOfKeyValueOfstringstringKeyValueOfstringstring in there.

Also that article you link appears to state that the Dictionary object
should not have this problem at all, because it already assumes the
client will know its getting a Dictionary object? This is all very
confusing.

Thanks again for your attention to helping me solve this frustrating
problem :)

On Oct 18, 1:25 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...(a)spam.guard.caspershouse.com> wrote:
> Zack,
>
> I misspoke. The dialog for VS.NET is going to be in the 2008 version.
> However, you can still use the /ct (or /collectionType) flag using the
> svcutil command line app to generate the proxy, and then add that to your
> project. For more details, see:
>
> http://www.request-response.com/blog/PermaLink,guid,ff5fab81-affb-4b2...
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - m...(a)spam.guard.caspershouse.com
>
> <zackary.ev...(a)gmail.com> wrote in message
>
> news:1192727531.053875.307990(a)q5g2000prf.googlegroups.com...
>
> > It was generated in VS.NET (2005) using the "Add Service Reference"
> > menu. I do not see a service reference settings dialog though. How do
> > I get there?
>
> > thanks!
>
> > Zack
>
> > On Oct 18, 12:15 pm, "Nicholas Paldino [.NET/C# MVP]"
> > <m...(a)spam.guard.caspershouse.com> wrote:
> >> Zack,
>
> >> How did you generate the proxy? If through VS.NET, did you set the
> >> dictionary collection type in the service reference settings dialog? If
> >> you
> >> did it through the svcutil utility, then did you use the /collectionType
> >> (or
> >> /ct) flag? You need to specify what to use as a collection type in the
> >> proxy.
>
> >> --
> >> - Nicholas Paldino [.NET/C# MVP]
> >> - m...(a)spam.guard.caspershouse.com
>
> >> <zackary.ev...(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;
> >> > }
> >> > }
> >> > }