我有,我正在尝试使用send()方法..至今没有运气发送结构一个UDP服务器...如何通过UDP套接字连接发送课程?
这是我在用的:
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说什么的突破吗?
你是什么意思发送一类的思想?你想序列化并通过远程发送? – GrayWizardx 2009-12-28 05:16:53
@Y_Y:你可能要考虑不这样做,直到你了解到一个类和一个实例之间的差异。 – 2009-12-28 05:25:06
是的..序列化... – 2009-12-28 05:25:39