我有一个 UDP 服务器,我正在尝试使用 send() 方法发送结构.. 到目前为止没有运气......
这就是我正在使用的:
H,G 是结构...
发送方:
IFormatter formatter = new BinaryFormatter();
MemoryStream stream = new MemoryStream();
formatter.Serialize(stream, H);
Byte[] buffer = stream.ToArray();
stream.Close();
在接收方:
IFormatter formatter = new BinaryFormatter();
Stream s = new MemoryStream(buffer.Data);
ClientAnswerStruct G = (ClientAnswerStruct)formatter.Deserialize(s);
s.Close();
MessageBox.Show(G.name);
但我得到这个错误:
Unable to find assembly 'UdpClientSample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
'UdpClientSample' 恰好是将数据发送到服务器的客户端程序的标题......所以我想知道是否需要序列化才能通过 UDP 连接发送结构?
那里有什么突破可以解释 Iamamac 所说的吗?