i need to pass an unknown type from my client to a wcf service ,
the type is unknown to the service .
for instance i have a class Customer which i create an instance of serialize and send to the service , the problem arises when i need to deserialize i have to provide the type in order to cast the desrialized object to .
Type can’t be serialized , when attempted i get the following error :
{"Type 'System.RuntimeType' with data contract name
'RuntimeType:http://schemas.datacontract.org/2004/07/System' is not expected. Consider
using a DataContractResolver or add any types not known statically to the list of
known types - for example, by using the KnownTypeAttribute attribute or by adding
them to the list of known types passed to DataContractSerializer."}
i need to find a work around for this issue , any ideas ?
just to summarize :
i’m looking for a workaround for sending an unknown Type to a WCF service .
If the other end doesn’t know anything about it (comments), then you can’t possibly deserialize. You couldn’t do that even with Type-based serializers (BinaryFormatter/NetDataContractSerializer).
If you are sending completely foreign data, then you are basically limited to things like XML or JSON, and even then the meaning is slightly ambiguous (is
<id>123<id>a string? int? float? long?).WCF is not well suited to your scenario (nor most other contract-based stacks; most systems expect to be able to understand incoming data).