(De-) Serialize between Rhino3dmIO and RhinoCommon problem

Lets say i create a PolylineCurve in Visual Studio and Rhino3dmIO and pack it in a binary stream, send it to Rhino and want to deserialize it back to a PolylineCurve. This does not work as they are from different a assembly (Rhino3dmIO and RhinoCommon respectively)

What would be the best way to go about that? It should work with all kinds of geometry…
thanks!

difference as string here:

Hi @atair,

Look into implementing a SerializationBinder. Here is an example:

– Dale

1 Like

or use json.net

1 Like

thanks! will try both

ok with Json i managed it more or less - a few questions:

  • Json: if i de-serialize a Object in Rhino i cant go directly to Geometrybase as it is protected. I have to know the type in advance. Any suggestions how to avoid that?

  • Rockfish: runs into the same problem - either i build rockfish with rhino3dmio and then there is a mismatch as the de-serialization takes place with rhinocommon, or i build the rockfish library with rhinocommon, but then when running its start to ask for rhinocommon_c and others. As far as i understand Rhinocommon and dependencies are ‘bound’ to rhino - in terms of license etc.? a bit of a chicken-egg problem

You don’t need to build the Rockfish project, and you certainly don’t need to build it into RhinoCommon or Rhino3dm. The code as only for you to use a reference.

That said, a SerializationBinder is exactly what you need, if I understand what you are trying to do.

There is an additional example:

https://www.codeproject.com/Tips/1101106/How-to-Serialize-Across-Assemblies-with-the-Binary

– Dale