When you serialize an object using the BinaryFormatter
, it includes information about what assembly the object came from. When deserializing it on the server, it reads that information and looks for the version of the retobj
class from the client assembly, which is why you get that error. The one on the server is not the same.
Try moving that class to a Class Library project, and referencing that project from both the client and the server. You don't need two copies.
An alternative approach would be to use an alternate formatter, like the DataContractSerializer, that does not embed assembly information.