I have a Silverlight 4 project that contains some business objects. I added a Test project. One of the tests is to serialize the business objects from the Silverlight project using DataContractSerializer
. To reference DataContractAttribute
, I have to add a reference to System.Runtime.Serialization
. However, there are different and apparently incompatible versions in the Silverlight runtime and in the .NET 4 Runtime of the Test project.
What's the best strategy to serialize objects in a Silverlight project such that they can be consumed by a standard .NET 4 runtime?
I realized this morning that I had added a reference to a Silverlight project from a non-Silverlight project and VS warned about that not being a good idea, but still allowed the non-Silverlight project to run. Because a different version of System.Runtime.Serialization
was referenced in each project, the unit test aborted with an inability to load that DLL.