反序列化 提示无法找到程序集

黎小黎 黎小黎 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
代码如下
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 为什么还提示无法找到程序集呢?
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
黎小黎
C# 111,128 成员 642,536 内容