XML serialization

Posts   
 
    
Seanw
User
Posts: 9
Joined: 30-Nov-2005
# Posted on: 10-Jan-2006 06:29:45   

Hi,

I am serializing an entitiy collection to Xml,


If MaintExpHouse.ContainsDirtyContents Then
                Dim writer As New StreamWriter("MainExpHouse.XML")
                Dim customerXml As String = String.Empty
                MaintExpHouse.WriteXml( _
XmlFormatAspect.Compact Or XmlFormatAspect.DatesInXmlDataType Or XmlFormatAspect.MLTextInCDataBlocks, customerXml)

                writer.Write(customerXml)
                writer.Close()
            End If


The entity been written is a matrix of 200 rows x 8 columns. This never grows in length only the content is edited.

The initial produced Xml file is about 300kb.

After a few more saves, the Xml file in a short time raplidy grows. One test I done was, after 10 saves this file was now 22mb.

What appears to be appended to the end of the XML file is these lines

<ProcessedObjectReference ObjectID="59c82c3b-4e72-459e-8fe2-c7085ff6b949" />

Is there a way to prevent this rapid growth ? or suppress these line being written to the file.

Again the matrix is not growing in size between these saves.

PS I am using this code to read the Xml back into the entity.


  Dim reader As New StreamReader("MaintInternal.XML")
            Dim xmlFromFile As String = reader.ReadToEnd()
            reader.Close()
            Me.MaintInternal.ReadXml(xmlFromFile)
            Me.dgMaint.DataSource = MaintInternal


Thanks,

Sean

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 10-Jan-2006 14:35:22   

Most probably there are entities added as references associated to your entity. Those lines are references to other entities not yet processed (cyclic references) Please check the xml after 1 save and see if something new is added. Thanks.

Seanw
User
Posts: 9
Joined: 30-Nov-2005
# Posted on: 11-Jan-2006 14:12:09   

Thanks Walaa

Yes 1 save did not produce the added Xml tags.

I found a more efficient way to instantiate the entity collections and it all works fine.

I was using the same collection between different Xml read and writes. Now I instantiate a new collection prior to every read.

Sean