user1897603
user1897603

Reputation:

Why cant a web service return a dictionary?

I have an ASMX web service that returns a dictionary but get an error each time it is posting

type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[BL.Customer, BL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] is not supported because it implements IDictionary

Upvotes: 1

Views: 2005

Answers (2)

John Saunders
John Saunders

Reputation: 161821

Even if you could serialize the dictionary, SOAP has no representation of a dictionary-type structure. The client would have no idea that the service was sending a dictionary.

Upvotes: 1

dizzytri99er
dizzytri99er

Reputation: 930

Best to post the error you are actually recieving but as it goes....... IDictionaries are not supported by web services by default so it is best to serialise the dictionary you are parsing. This article shows how to serialise the IDictionary

Upvotes: 1

Related Questions