From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Replicating Serialization/Deserialization in LabVIEW

Hi all,

 

I have very little experience with .net and C# so forgive me if this is a stupid question.

 

I am attempting to read and replicate a file structure from an old software program that I am using. The files are saved using the binary formatter serialization (formatter.Serialize()).

 

Is there a way to read this in LabVIEW (i.e. perform the formatter.Deserialize()) and create similar files in the same format?

 

Thanks,

 

Scot07

0 Kudos
Message 1 of 4
(1,245 Views)

You can use .net functions in LabVIEW directly: https://zone.ni.com/reference/en-XX/help/371361R-01/lvconcepts/using__net_with_labview/

 

I guess this will only be useful if You can recreate the original data type, though.

0 Kudos
Message 2 of 4
(1,227 Views)

Thank you for replying. 

 

I have gone down the rabbit hole following that link and others. However, I am not experienced with .net

 

In terms of recreating the original data type - I know what to expect to come back as I have the C# scripts that use this data. 

 

I've attached a copy of the script (edited obviously) and where I have got to with the Labview program. 

 

I am not sure how to progress from here. 

 

Any help would be greatly appreciated. 

 

Thanks,

 

Scot07

0 Kudos
Message 3 of 4
(1,163 Views)

I'm no expert in C# either, but I guess You need to get "Class1" (and probably Class2 and Class3) into LabVIEW. Depending on where You get them from, this may involve compiling them as a C#-Assembly and/or adding that assembly. From there, You can use "to specific class" to do the object casting.

 

Since You have access to the original code working with the data, maybe it would be easier to directly use C# and convert the data to a format directly usable to You? This may be a good decision anyway, as Microsoft has marked the BinaryFormatter as dangerous, obsolete and insecure (https://docs.microsoft.com/en-gb/dotnet/standard/serialization/binaryformatter-security-guide)

0 Kudos
Message 4 of 4
(1,136 Views)