Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm having a problem with a WCF call where [ServiceKnownType] is required.

the relevant service contract has
[ServiceKnownType(typeof(List<Object))] 



But when I make a call to it, I get ArrayOfanyType is not expected and advice to use the ServiceKnownType or DataContractResolved.

In order to pass the list I have to open Reference.cs on the client side and change:
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(object[]))]

to
using System;
using System.Collections.Generic;
       // [System.ServiceModel.ServiceKnownTypeAttribute(typeof(object[]))]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(List<object>))]


Which begs the question
how or why does service entry
[ServiceKnownType(typeof(List<Object>))]

become client entry
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(object[]))]


and what can be done to prevent this?
Posted
Updated 13-Mar-13 8:24am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900