I have to identical applications written by me operating on two different machines. I want to send either a complete instance of a form across a TCP/IP network to a peer machine, or at least the class other information necessary to recreate the form on the remote computer. I believe it can be achieved with a TCP/IP client and employing the use of unsafe memory pointers to access the memory space of the form. Surely there are simpler ways to achieve this???
Any ideas greatfully accepted.
Sending an instance of a form and all it's info from Computer A to Computer B
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
AnttiRank #9,295 · 208 pointsPosted Feb 9, 2006, 10:26 PM EST
How does the unmanaged pointers help when transferring data over network...? Other machine can never access directly to other machine.
Well, you could make a custom carrier class, which can carry all relevant information you need to duplicate the form behaviour at the other machine. Serializing the whole System.Windows.Form would be quite useless.
The carrier object would be serialized in local machine to xml or binary, and transferred to the remote machine, and deserialized there, and new form is initialized there according to the information of the carrier object.
This is the way I would do it:
1) create form
2) create and initialize carrier object
3) serialize carrier to either xml or binary
4) transfer carrier to other machine over the protocol you choose
5) deserialize carrier data to carrier object
6) create and initialize your new form using carrier's data
7) show your form
Transferring data to xml is simple using XmlSerializer-object. See MSDN for an example. Well, you could try to serialize the whole Form object, but it consumes lots of network resources, since it has many, many fields. But if the transfer is happening quite seldom, go ahead.
cfqueb14 pointsPosted Feb 10, 2006, 10:27 AM EST
Anwar Buchoo89 pointsPosted Feb 21, 2006, 9:40 PM EST
Items That Can Be Serialized:
The following items can be serialized using the XmlSerializer class.
(source MSDN online help)