问题场景:
有两个结构完全相同的类,一个写在client端,一个写在server端. 单独测试任何一个类都没有问题,但client端发送类的实例(对象)给server端时,server端在反序列化对象时提示: "无法找到程序集“client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”.
问题原因:
虽然client端和server端的这两个类的结构完全相同,但由于它们分别位于各自的namespace下,就导致了对象在反序列化时出现错误。
解决办法:
写一个公用类库,把client端和server端都要用到的这个类写到此类库中,然后让client端和server端都引用这个公用类库(dll),这样位于同一个namespace下的类的实例在反序列化时就不会出错了.