I am using Silverlight with WCF. I have a fairly complicated object that I am wanting to send to the server. This object is shared among multiple services and so cannot be a data contract. I am wondering if there is a simple way to do the serialization myself. A way that works for both .Net 4 (server side) and Silverlight 4 (client side).
Note, I am not using RIA Services, because RIA Services has been a huge pain in my side since I started using it.
Edits:
I've attempted to use the DataContractAttribute and DataMemberAttribute to no avail. I get the following exception from the service:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified. File name: 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'
The reason seems evident. I believe it is because the DLL that contains the POCO is a Silverlight Class Library. This is the only way I know to share the object between both my WCF Service and my Silverlight Client. The problem, I believe, is that the Silverlight DLL is using the Silverlight version of System.Runtime.Serialization and therefore the POCO cannot be used in a non Silverlight environment. I have to share this POCO among multiple services so it has to exist in a separate Assembly.
This is why I want to control how I serialize my objects; serialize them inside the objects themselves.