problem with loading XML data

Posts   
 
    
sun450
User
Posts: 4
Joined: 07-Dec-2004
# Posted on: 20-Nov-2008 18:08:31   

I am using latest version 1.0.2004.1 version. But I got the problems for the following XML saving and loading functions.

The saving is always working, but the loading gives errors if there is data for the related table.

the shema is like following: Customer has 0 or 1 CustAdditional info. If the CustAdditional is 0 (ie. no data), the loading is ok. otherwise the error occurs.

Error happens in this line in loading method: collection.ReadXml(doc.OuterXml)

"The field is marked readonly and cannot be changed."

" at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value) at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Xml2Entity(XmlNode node, Hashtable processedObjectIDs, ArrayList nodeEntityReferences) at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase.Xml2EntityCollection(XmlNode node, Hashtable processedObjectIDs, ArrayList nodeEntityReferences) at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase.ReadXml(XmlNode node) at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase.ReadXml(String xmlData) at XMLIO.loadXMLCollection(EntityCollectionBase& collection, String filename) in D:\WMS\WMSAF3.0-SourceCode\CSMAT\CSMAT.DAL\XMLIO.vb:line 198 at CSMAT.GUI.ModuleFacade.LoadXMLCustomer() in D:\WMS\WMSAF3.0-SourceCode\CSMAT\CSMAT.GUI\ModuleFacade.vb:line 137"

  Public Shared Sub saveXMLCustomerCollection(ByRef collection As CustomerCollection)
       Dim path As String = getPath("Customer")

        collection.SupportsSorting = True
        Dim prop As EntityPropertyDescriptor = New EntityPropertyDescriptor(EntityFieldFactory.Create(CSMAT.DAL.CustomerFieldIndex.CustId), GetType(CustomerEntity))
        collection.ApplySort(prop, System.ComponentModel.ListSortDirection.Ascending)

        Dim xml As New xml.XmlDocument
        Dim node As xml.XmlNode
        Dim xmls As String

        collection.WriteXml("CustomerEntityCollection", xmls)
        xml.LoadXml(xmls)


        'Testing the existance of the destination path
        Dim dir As System.IO.Directory
        Dim dstring As String = getDIR()
        If Not dir.Exists(Application.StartupPath & dstring) Then
            dir.CreateDirectory(Application.StartupPath & dstring)
        End If
        xml.Save(Application.StartupPath & path)

    End Sub

    Public Shared Function loadXMLCollection(ByRef collection As EntityCollectionBase, ByVal filename As String) As Boolean

        Dim path As String = getPath(filename)

        Dim file As System.IO.File
        If file.Exists(Application.StartupPath & path) Then
            Dim doc As New Xml.XmlDocument
            doc.Load(Application.StartupPath & path)
            collection.ReadXml(doc.OuterXml)
            Cursor.Current() = System.Windows.Forms.Cursors.Default
            Return True
        End If
        Return False
    End Function
Attachments
Filename File size Added on Approval
Customer(error).xml 25,192 20-Nov-2008 18:08.56 Approved
MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 20-Nov-2008 21:20:35   

1.0.2004.1 is now somewhat over 3 years old, and is no longer the latest version. Could you download the latest version (2.6) and try with that.

There have been many issues fixed in the last 3 years simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 21-Nov-2008 16:02:40   

As an upgrade to 2.0 costs money, at least try to upgrade to v1.0.2004.2, which is free for you (see customer area) or v1.0.2005.1 (also free upgrade for you).

This problem sounds like an issue which is fixed a long time ago. If you really can't upgrade to v1.0.2004.2, please let us know.

Frans Bouma | Lead developer LLBLGen Pro
sun450
User
Posts: 4
Joined: 07-Dec-2004
# Posted on: 23-Nov-2008 07:58:05   

Otis wrote:

As an upgrade to 2.0 costs money, at least try to upgrade to v1.0.2004.2, which is free for you (see customer area) or v1.0.2005.1 (also free upgrade for you).

This problem sounds like an issue which is fixed a long time ago. If you really can't upgrade to v1.0.2004.2, please let us know.

Hi Otis,

Thank you very much for the reply. But upgrading for us means we need to regenerate all of the codes, roughtly we have ten projects. the rest 9 is working fine. only this project uses this exporting function.

Is there a way to solve this problem in the code? Or I must upgrade the dll to 2004.2?

Many Thanks and Best Regards, Liu Yang

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 23-Nov-2008 19:38:34   

The better approach is update to the 1.0.2004.2 or better 1.0.2005.1.

  • Please try moving to those versions to confirm the problem is gone. So try this:
  • Make a backup of your project.
  • Re-referencing the ORMSupportClasses assembly on your project with new version.
  • Compile and run your test.
  • If step 2 still fails, maybe you will need to regenerate code. So do it with the new version.
  • Back to step 2.

You don't need to upgrade (nor regenerate code) all your projects although it may be wise to do it.

David Elizondo | LLBLGen Support Team