当使用WebMethod返回自定义对象时,生成本地代理类时,会抹去你定义的Private成员和方法。  
  你只有将对象进行二进制序列化再反序列化。  
   
  http://community.csdn.net/Expert/topic/3929/3929625.xml?temp=.1452753  
   
   
  public   static   byte[]   BinarySerialize(object   obj)  
  {  
  BinaryFormatter   bf   =   new   BinaryFormatter();  
  using(MemoryStream   ms   =   new   MemoryStream())  
  {  
  bf.Serialize(ms,   obj);  
  ms.Close();  
  return   ms.ToArray();  
  }  
   
  }  
   
  public   static   object   BinaryDeserialize(byte[]   bytes)  
  {  
  BinaryFormatter   bf   =   new   BinaryFormatter();  
  object   obj;  
  using(MemoryStream   ms   =   new   MemoryStream(bytes))  
  {  
  obj   =   bf.Deserialize(ms);  
          ms.Close();  
  }  
  return   obj;  
  }   
    
   

相关文章:

  • 2022-02-05
  • 2022-12-23
  • 2021-10-13
  • 2021-04-08
  • 2021-09-25
  • 2022-12-23
  • 2021-10-14
猜你喜欢
  • 2022-12-23
  • 2021-08-31
  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
  • 2021-10-20
  • 2021-11-09
相关资源
相似解决方案