protobuf-net as wcf serializer with object in OperationContract -


i have project uses wcf. uses netdatacontractserializer. want migrate protobuf-net. service has folowing contract:

interface iremotingserver {     [operationcontract]     typeconfig gettypeconfig(string typename);      [operationcontract]     object executemethod(instanceidentifier instance, string methodname, object[] parameters);      [operationcontract]     object executegenericmethod(instanceidentifier instance, string methodname, object[] parameters, string[] generictypes, string returntype);      [operationcontract]     object getremoteproperty(instanceidentifier instance, string propertyname);      [operationcontract]     void setremoteproperty(instanceidentifier instance, string propertyname, object value);            [operationcontract]     objectdatapacket getobject(instanceidentifier instance);      [operationcontract]     bool connect();      [operationcontract]     bool disconnect(); } 

things goes fine, until try call getremoteproperty method of contract return type object. using server traces found, server blows folowing message

there error while trying serialize parameter http://www.mersoft.am/remoting:getremotepropertyresult. innerexception message 'type 'mersoft.remoting.instanceidentifier[]' data contract name 'arrayofinstanceidentifier:mersoft.remoting' not expected. consider using datacontractresolver or add types not known statically list of known types - example, using knowntypeattribute attribute or adding them list of known types passed datacontractserializer.'. please see innerexception more details.

so, how can fix it?

basically, returning object going huge problem serializer isn't binaryformatter or netdatacontractserializer; returning object doesn't work , inappropriate on general purpose wcf boundary. protobuf-net, in common serializers (including datacontractserializer, xmlserializer, json.net, etc) wants know more object; simply, not enough information deserialize in scenarios.

as long return object, isn't going work protobuf-net (or, noted, serializers). @ moment, protooperationbehavior inherits datacontractserializeroperationbehavior; 1 possible option write version of defaults netdatacontractserializer rather datacontractserializer - mean unknown types serialized netdatacontractserializer instead; of course, still wouldn't use protobuf-net object, because can't.


Comments