udpソケットなどを学習しようとしています。サーバーとクライアントの2つのプログラムを作成しました。クライアントはパケットをサーバーに送信し、サーバーはそれをバウンスします。
これは、データをbyte[]との間で変換するために両方のプログラムで使用するコードです。
しかし、byte[]から変換するときにエラーが発生します
public static Packet Open(byte[] b)
{
MemoryStream memStream = new MemoryStream();
BinaryFormatter binForm = new BinaryFormatter();
memStream.Write(b, 0, b.Length);
memStream.Seek(0, SeekOrigin.Begin);
object obj = new object();
try
{
// this line here is where the error is occurring
obj = (object)binForm.Deserialize(memStream);
}
catch (Exception er)
{
MessageBox.Show(er.Message);
}
if (obj is Packet)
return (Packet)obj;
else
return null;
}
public byte[] Bundle()
{
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, this);
return ms.ToArray();
}
これを行うと、すべて1つのプログラムから機能します
Packet p =new Packet();
p.Message="hello";
byte[] data = p.Bundle();
Packet p2 = Packet.Open(data);
MessageBox.Show(p2.Message);
私が受け取っているエラーは、「「クライアントプログラムの名前」でアセンブリが見つかりません」です。
何か案は?