简体   繁体   中英

Problem passing IEnumerable<IDictionary> over WCF to Silverlight

I have a WCF service which I am trying to use to generate an IEnumerable<IDictionary> and then build a grid on the fly from this.

The method signature on the server that returns the data is:

[OperationContract]
[FaultContract(typeof(GeneralServiceFault))]
IEnumerable<IDictionary> GetReport(string name, ReportingParameter[] parameters);

I'm building my service reference using:

call "C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Tools\slsvcutil.exe" http://localhost:8082/Service?wsdl /mergeConfig /config:..\ServiceReferences.ClientConfig /edb /namespace:"*,namespace.Service" /r:"c:\Program Files\Microsoft Silverlight\4.0.60129.0\System.Windows.dll"

This generates a service reference which boils down to:

 public Dictionary<object, object>[] EndGetReport(IAsyncResult result)

Is there anyway I can get this to generate with the generic IDictionary so I can call the extension method found here ? Or if not how should I go about doing this?

I don't think that's possible...
Just change that extension method to:

public static IEnumerable ToDataSource<TDictionary>(
          this IEnumerable<TDictionary> list) where TDictionary : IDictionary

If you're using / have access to Visual Studio, then try this:

  • Right-click the Service Reference for the service within Visual Studio Solution Explorer

  • Select the option which reads 'Configure Service Reference'

  • Make sure the Collection Type specified is System.Collections.Generic.List

  • Make sure the Dictionary collection type specified is System.Collections.Generic.Dictionary

Apologies, but I'm not familiar with the command-line reference of svcutil for generating anything other than a default configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM