How do I serialize a CustomCurveObject?

I have a tricky problem. I have defined a custom object by inheriting CustomCurveObject, but I cannot save it. Re-open the document and the object is converted to curveObject. :sob: :sob:

The idea is that you write something to the document in PlugIn.WriteDocument (note: you must also override PlugIn.ShouldWriteDocument otherwise WriteDocument is not called).
In the document you write for example which Guids are CustomCurveObjects.
Then, when PlugIn.ReadDocument is called, you read back the Guids that were custom curve objects. But you can’t modify the document while it is being read! So subscribe to RhinoDoc.EndOpenDocument and then do whatever it is that needs to be done to replace the objects with your CustomCurveObject implementation.

This approach is taken to support loading the file without having your plug-in loaded, in that case, the objects are loaded as normal curves.