views:

27

answers:

1

hi,

I have methods which return interface and some methods which accepts interface as parameters. I am trying to use Net DataContractSerializer but I am getting following error...

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:id. The InnerException message was 'Error in line 1 position 120. XML 'Element' 'http://tempuri.org/:id' 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.

Please help me how to resolve this error....

If I use Netdatacontract attribute on Operation Contract, can i use DataContract and Datamember attribute on serializable class???

Thanks in advance...

A: 

Just guessing - the error seems to indicate the NetDataContractSerializer can't properly determine what type to deserialize your content into.

Could it be that you're not specifying the http://tempuri.org XML namespace to the deserializer??

Also, can you show the content of the InnerException, please?

Or second option: using the NetDataContractSerializer, you need to also share the data contracts between server and client, so that the client can deserialize to the exact same type as was defined on the server side. Are you missing this requirement, maybe??

marc_s
Hii... Thank you for your response.... I have created Datacontract class as seperate .net library and added reference to client and server to share types. And coming to name space iam using my project namespace at that place.. If you have any idea about what namespae to use please let me know..My Inner exception is also the same thing that deserialization error. Below is the code I am using to enable NetDcs. Please let me know if this is correct..
http://www.pluralsight-training.net/community/blogs/aaron/archive/2006/04/21/22284.aspxThe code is in the above link... Please let me know if i have to make any changes in that code and any changes required for config files...Thanks in advance...