反序列化 提示无法找到程序集
黎小黎 2013-05-21 06:23:00 代码如下
if (sendStream != null)
{
IFormatter serializer = new BinaryFormatter();
serializer.Binder = new UBinder();
receiveStream = serializer.Deserialize(sendStream) as SendData;//反序列化 这句没有执行 提示无法找到程序集
receiveStream 已经在之前申明了 public SendData receiveStream = new SendData();
SendData 类
namespace songshu
{
[Serializable]
class SendData //发送数据结构
{
public int sendID; //发送序号
public IPAddress sendIP; //发送IP
public int sendPort; //发送端口
public int sqlSystem; //数据库类型:1 SQLServer;2 Acess;3 Oracle
public string hostName; //数据库主机名称
public string dataName; //数据库名称
public string tableName; //数据表名称
public string userName; //数据库用户名
public string password; //数据库密码
public DataSet sendData_insert; //传输插入数据库
public DataSet sendData_updata; //传输更改数据库
public DataSet sendData_delete; //传输删除数据库
}
}
UBinder类
public class UBinder : SerializationBinder
{
public override Type BindToType(string assemblyName, string typeName)
{
Assembly ass = Assembly.GetExecutingAssembly();
return ass.GetType(typeName);
}
}
发送端和接受端都用的相同结构的 senddata 为什么还提示无法找到程序集呢?