Transfering大会通过TCP [英] Transfering Assembly over TCP
问题描述
目前我正在试图发送一个序列化对象通过TCP连接如下 -
I am currently trying to send a serialized object over a TCP connection as follows -
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(clientStream, (Object)Assembly.LoadFrom("test.dll"));
其中,clientStream为
where clientStream is
TcpClient tcpClient = (TcpClient)client;
NetworkStream clientStream = tcpClient.GetStream();
这是发送部分。但谁能告诉我,我该怎么办收到此在客户端(即反序列化的另一端)?
This is the sending part. But can anyone tell me how do I receive this on the client side (i.e. deserialize it on the other end)?
推荐答案
不要序列组装。只是通过加载它作为一个文件和发送这些字节到另一侧发送组件本身
Don't serialize the assembly. Send the assembly itself just by loading it as a file and sending those bytes to the other side.
然后,当双方有相同的code,通过序列化发送的对象。我相信这反序列化对象的AppDomain中必须有相关的组件加载(或至少可以被加载)。
Then, when both sides have the same code, send the object via serialization. I believe the AppDomain which deserializes the object will have to have the relevant assembly loaded (or at least available to be loaded).
这篇关于Transfering大会通过TCP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!