brimcd
2008-08-12 21:40:22 UTC
I'm trying to deserialize a memory stream sent from a MS .Net3.5 application via UDP to a Labview client. My options seemed to be:
1) a CIN - which I have mostly done and can probably finish up
2) a DLL - but I can't figure out how to invoke managed code
3) use the LV .Net Constructor node and Invoke node. This seemed to be the simplest, but I cannot get the deserialization to work.
To test,
--I create a Binary Formatter (Constructor Node) and a Memory Stream (Constructor Node), ,then use the Binary Formatter (Invoke Node) to serialize a .Net Object dreated from an array. This seems to work, though I cannot figure out how to 'see' the serialized stream.
The main problem is deserialization, where I cannot create any method (using Invoke Node) of the Binary formatter that allows me to input the stream.
The equivalent c++ code is fairly simple:
Create a stream and serialize the object, and send to byte array:
MemoryStream ms = new MemoryStream(); string theSerializedObject;
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(ms, ObjectToSerialize); byte[] thisByteArray = ms.ToArray();
Grab byte array from transmitted string, create the mem stream, and deserialize the data:
byte[] thisByteArray = Convert.FromBase64String(StringToDeserialize); MemoryStream ms = new MemoryStream(thisByteArray); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
Attached is an attempt to duplicate these steps in LV, without any luck.
I appreciate any ideas or samples.
Thanks,
Brian
1) a CIN - which I have mostly done and can probably finish up
2) a DLL - but I can't figure out how to invoke managed code
3) use the LV .Net Constructor node and Invoke node. This seemed to be the simplest, but I cannot get the deserialization to work.
To test,
--I create a Binary Formatter (Constructor Node) and a Memory Stream (Constructor Node), ,then use the Binary Formatter (Invoke Node) to serialize a .Net Object dreated from an array. This seems to work, though I cannot figure out how to 'see' the serialized stream.
The main problem is deserialization, where I cannot create any method (using Invoke Node) of the Binary formatter that allows me to input the stream.
The equivalent c++ code is fairly simple:
Create a stream and serialize the object, and send to byte array:
MemoryStream ms = new MemoryStream(); string theSerializedObject;
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(ms, ObjectToSerialize); byte[] thisByteArray = ms.ToArray();
Grab byte array from transmitted string, create the mem stream, and deserialize the data:
byte[] thisByteArray = Convert.FromBase64String(StringToDeserialize); MemoryStream ms = new MemoryStream(thisByteArray); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
Attached is an attempt to duplicate these steps in LV, without any luck.
I appreciate any ideas or samples.
Thanks,
Brian