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.
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.
02-16-2021 10:27 AM
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
02-16-2021 10:57 AM
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.
02-18-2021 03:19 PM
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
02-19-2021 09:25 AM - edited 02-19-2021 09:37 AM
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)