Profile Picture

Diagram custom serialization

Posted By Eric Taymans 12 Years Ago
Author
Message
Eric Taymans
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 0, Visits: 1

I use Nevron Diagram for .Net (Windows forms) to create an object model. I have subclassed shapes to hold my own objects. I want to store the NDocuments with their shapes and my own objects related to the shapes in one binary file.

 

I use one object, myModel, of my class Model containing all related objects and NDocuments.

Before serializing my model object with the following code:

 

  Dim fs As FileStream = New FileStream(filePath, FileMode.Create)

  Dim bf As New BinaryFormatter(Nothing, New StreamingContext(StreamingContextStates.File))

   bf.Serialize(fs, myModel)

   fs.Close()

the following code is executed on each NDocument:

aNDocument.OnSerializing()

 

To load the binary file, the following code is used:

 Dim fs As FileStream = New FileStream(filePath, FileMode.Open)

        Dim bf As New BinaryFormatter(Nothing, New StreamingContext(StreamingContextStates.File))

        mModel = bf.Deserialize(fs)

        fs.Close()

 

After the loading, the following code is executed on each NDocument:

aNDocument.OnDeserialized()

 

It works fine the first time. But after a second save and load the following error occurs on the OnDeserialized method:

 

System.Exception occurred

  Message=The element or one of its descendants has an invalid id

  Source=Nevron.System

  StackTrace:

       at Nevron.Dom.NElementIndex.Rebuild(INElement element)

       at Nevron.Diagram.NDocument.OnDeserialized()

       at SF.Model.OnDeserialized() in C:\Users\ET\Documents\Visual Studio 2010\Projects\SF5\SF5\Model.vb:line 786

  InnerException:

 

Looking at the documentation, I know that there is a Persistency Manager that can be used to save drawings to file but I need to save a whole graph of Nevron objects with my own objects.

I have also seen NReflector.UpdateReferences but I am not sure how and when to use it.

 

Could you help me?

 

Thanks

 

Eric

 






Similar Topics


Reading This Topic