c# - KeyValuePair in WCF Service -


i have wcf service, method updateproperty take propertyvalue in parameter :

void updateproperty(propertyvalue propertyvalue)  [datacontract] public class propertyvalue {     [datamember]     public string property { get; private set; }      [datamember]     public object value { get; private set; } } 

i'm trying call method keyvaluepair value, , i'm getting error :

"the formatter threw exception while trying deserialize message: there error while trying deserialize parameter http://tempuri.org/:propertyvalue. innerexception message 'error in line 1 position 544. element 'http://schemas.datacontract.org/2004/07/myproject.datacontracts:value' contains data type maps name 'http://schemas.datacontract.org/2004/07/system.collections.generic:keyvaluepairofanytypeanytype'. deserializer has no knowledge of type maps name. consider using datacontractresolver if using datacontractserializer or add type corresponding 'keyvaluepairofanytypeanytype' list of known types - example, using knowntypeattribute attribute or adding list of known types passed serializer.'. please see innerexception more details."

i tried add knowntype on class still error :

[knowntype(typeof(keyvaluepair<object, object>))] 

any idea why ? i'm using other keyvaluepair in other method (as parameter) without problem...

in soap body, have :

    <d4p1:value xmlns:d7p1="http://schemas.datacontract.org/2004/07/system.collections.generic" i:type="d7p1:keyvaluepairofanytypeanytype">       <d7p1:key>test</d7p1:key>       <d7p1:value>test</d7p1:value>     </d4p1:value> 

i guess know want. try object input:

    [serializable] public class webserviceinputgetdataparams : iserializable {     public dictionary<string, object> entries     {         { return entries; }     }       private dictionary<string, object> entries;     public webserviceinputgetdataparams()     {         entries = new dictionary<string, object>();     }     protected webserviceinputgetdataparams(serializationinfo info, streamingcontext context)     {         entries = new dictionary<string, object>();         foreach (var entry in info)         {             entries.add(entry.name, entry.value);         }     }     public void getobjectdata(serializationinfo info, streamingcontext context)     {         foreach (var entry in entries)         {             info.addvalue(entry.key, entry.value);         }     } } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -