views:

166

answers:

2

Hi,

I'm generating proxy using svcutil tool. My contract methods return objects of particular type. However generated proxy client interface has return value of type object. What is more I get exception with message:

System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail] : The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:name. The InnerException message was 'XML 'Element' 'http://tempuri.org/:name' does not contain expected attribute 'http://schemas.microsoft.com/2003/10/Serialization/:Type'. The deserializer has no knowledge of which type to deserialize. Check that the type being serialized has the same contract as the type being deserialized.'.  Please see InnerException for more details.

Any ideas what's going on?

A: 

It sounds like svcutil has problems understanding your types. If you have custom types defined in other assemblies you may need to use the [KnownType] attribute to tell svcutil what's going on.

See the MSDN reference here.

Jeremy McGee
Hmm, now I have noticed that type which is returned by service as a result is not decorated with DataContract attribute...That's the issue right?
dragonfly
That seems quite likely - try it!
Jeremy McGee
Hmm, that service returns interface. Interface cannot be decorated with DataContract attribute. What should I do then?
dragonfly
A: 

Hmmm, I'm new to WCF and project I'm exploring... However I have just noticed that data type which is returned by the service is not decorated with DataContract attributes. Is that the issue?

dragonfly