08-12-2008 04:36 PM
08-12-2008 05:01 PM
08-12-2008 05:06 PM
08-12-2008 05:15 PM
08-12-2008 05:28 PM
The attached TestSerialize.vi is simply an attempt to implement a standalone serialize-deserialize example, similar to the MS c++ .Net code shown, but written entirely in LV constructors and methods. If I could get that to work, I could probably implement the deserializer where I really need it. I just wanted to start off with a simple case to see if I could do it.
BTW - I don't think the wiring in this vi makes sense (there should be a serialized stream output going to an input for deserialization) but i canot find an appropriate method/connector.
I thought this would be a fairly easy example to implement in LV (serialize and deserialize _anything_ in the same app), but now my head hurts.
Thanks for your time,
Brian
08-13-2008 09:48 AM
Well, my head hurts too because I can't match your LabVIEW code to your text code. The LabVIEW constructors and methods are what the class exposes. It's not like LabVIEW makes up its own. Your text code says this:
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();
but your LabVIEW code (second frame) doesn't look anything like this, so I have no idea what I'm supposed to compare.
08-13-2008 05:36 PM
Sorry - obviously I'm not being clear.
Just ignore all the c++ code (pretend I never sent it), and see if is there any way to get my lv code to work?
I'd like to see an example where you
1) create an array in lv
2) call .Net constructors and methods to serialize a stream
3) call .Net constructors and methods to de-serialize that stream
4) re-create the array from the stream.
That is what I attempted to do in the lv code I attached, but never got the de-serialization part to work. The problem appears to be that I cannot find an output for the stream that is filled with data in the first sequence panel (the serializationStream) The BinaryFormatter-Serialize node in the first sequence panel has no output for that serialized stream - it is input only. So, how do I get access to that stream? Through the reference? My logic says I need to connect that stream in the first sequence panel with the 'serializationStream' input in the second panel, but I have no stream exiting the first panel, and cannot find one in any method available.
The code shows an attempt to use the MemoryStream reference, along with an attempt to make sure I'm reading from the start of the stream, but it fails.
I can do this with a CIN, but it gets a bit messy and I'd prefer this method if possible.
Thanks for your time,
Brian
08-14-2008 11:03 AM
08-14-2008 12:55 PM
EXACTLY!!
Many thanks - I couldn't put the pieces together like you did. I can work with this to do what I need.
Thanks,
Brian
12-28-2014 10:21 PM - edited 12-28-2014 10:23 PM
Hey, this is close to what I've been trying to do only that in my case, I am not initializing an array but wanting to have labview pick up memorystream that is running in a .NET (C#) application. Can you help?
Here's my c# code:
this.facePoints3D = frame.Get3DShape();
using (MemoryStream stream = new MemoryStream())
{
var sw = new StreamWriter(stream);
foreach (var vector in facePoints3D)
{
sw.WriteLine(vector.Z);
sw.Flush();
}
stream.Position = 0;
StreamWriter writemem = new StreamWriter("coordinates.txt", true);
using (writemem)
{
var read = new StreamReader(stream);
var myread = read.ReadToEnd();
writemem.WriteLine(myread);
}
}