各位大虾,小弟有一个client 端程序 和 一个 server端程序,从client端将一个结构体数组序列化后传给server端,然后server端进行反序列化,想得到这个结构体数组,但是反序列化时报错:
“无法找到程序集 ProcessWatch, Version=1.0.2412.32565, Culture=neutral, PublicKeyToken=null。” 其中,ProcessWatch是我的解决方案名称。如下:client端://序列化
System.IO.MemoryStream memStream = new System.IO.MemoryStream();
BinaryFormatter temp = new BinaryFormatter();
temp.Serialize(memStream,this.arrayStruct); //this.arrayStruct就是我那个结构体数组
memStream.Position = 0;
memStream.Read(this.byteArray,0,(int)memStream.Length);//this.byteArray就是我要传输用的 byte数组//传递
socket.BeginSend(this.byteArray,0,this.byteArray.Length,0,new AsyncCallback(SendCallback),sClient);server端:
//反序列化
System.IO.MemoryStream memStream = new System.IO.MemoryStream();
memStream.Write(buffer,0,buffer.Length);//buffer就是client端传过来的byte数组
memStream.Position = 0;this.arrayStruct = (InforServer[])temp1.Deserialize(memStream); //this.arrayStruct是和client端同样定义的结构体数组就在这最后一句报错:“无法找到程序集 ProcessWatch, Version=1.0.2412.32565, Culture=neutral, PublicKeyToken=null。” 
其中,ProcessWatch是我的解决方案名称。各位大虾,这是怎么回事啊,序列化和反序列化的操作,我在同一个程序中已经验证是可以的,为什么分成两个程序进行就错误了?难道是传输过程中有变化吗? 救命啊!!!

解决方案 »

  1.   

    反序列化不宜用List<>和Arraylist的类,参看MSDN
      

  2.   

    client 有没有包含对InforServer结构体的定义?
      

  3.   

    client 有没有包含对InforServer结构体的定义?-----有,server程序中也有,定义都是一样的:
    [Serializable]
    public struct InforServer 
    {
    public string strType;
    public string strName;
    public string strState;
    public string strErrorDescription; public InforServer(string strType,string strName,string strState,string strErrorDescription)
    {
    this.strType = strType;
    this.strName = strName;
    this.strState = strState;
    this.strErrorDescription = strErrorDescription;
    }
    }
      

  4.   

    结构体数组的定义,两边也一样:
    public InforServer[] arrayStruct = new InforServer[50];