Debugging BinaryArchiveReader.ReadString Method for Plugin Developers?

“ReadString failed” Exception

I am using this method to get archive dictionary from 3dm file:

protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
{
    ArchivableDictionary archiveDic = archive.ReadDictionary(); // "ReadString failed" EXCEPTİON!
    var structureData = StructureDataHandler.GetStructureData(doc);
    structureData.ReadDocument(archiveDic);
}

It works for almost all of the test files. However, I recieve “ReadString failed” excepiton for a single test file that is distinguished from others in terms of data size. It’s size is over 600 MB.

Two questions

  1. Are there any possibility that the ReadDictionary() is affected by the size of the data string?
  2. Are there any way to debug the exceptions thrown by the native calls?

Hi @Mustafa_şentürk,

Can you provide some sample code and a 3dm file that allows me to repeat this?

Thanks,

– Dale

Great, thanks! I am going to replicate the issue with the same files in a new project to share.

Let me a few hours.

I apologies in advance if I’ve overlooked something about this issue:

While working on reproducing the problem, I found out that it is not about the size of the archive data. My guess is that ArchiveDict gets broken when serialised geometry data, in this case a curve, is written to ArchiveDict. I have observed unpredictable behaviour when serialising and deserialising data and when writing/reading ArchiveDict.

Context

This is the result of a refactoring experiment where I tried to replace CurveObjects as a geometry resource as part of a geometric template with `Curve’.

Keeping CurveObjects as a source of geometry data within a model is not preferable as the objects are available to users and users can delete or modify the objects. Therefore, keeping Curve as the geometry data is experimented with.

Json serialisation is used to generate data strings.

Cases

Forexample reading ArchiveDict from this file throws “BinaryArchiveException”:

This is the plug-in file where the exception occurs.
PluginReadingArchiveDictPlugin.cs (3.5 KB)

This file on the other hand, can be read and deserialize objects successfully despite it is the output of the same plug-in.

I also have a tiny file that also contains serialised curve data, the ArchiveDict of this file can be read without exception. However, after deserialising it throws a “System.Runtime.Serialization.SerializationException: ‘archive3dm’ not found” after deserialized.

Unfortunately I am not allowed to share the project files, so I cannot replicate this problem.