ReadXml error

Posts   
 
    
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 05-Mar-2005 12:10:38   

I use the following helper functions to XML serialize/de-serialize entity objects.

    Private Shared Function VersionFileName(ByVal entity As IEntity2, ByVal versionName As String) As String
        Return String.Format("{0}.{1}", versionName, entity.ObjectID.ToString)
    End Function

    Public Shared Sub SaveEtityVersion(ByVal entity As IEntity2, ByVal versionName As String)

        Dim writer As System.io.StreamWriter

        writer = New System.io.StreamWriter(VersionFileName(entity, versionName))

        Dim cloneXML As String = String.Empty
        entity.WriteXml(cloneXML)

        writer.Write(cloneXML)
        writer.Close()

    End Sub

    Public Shared Sub RollbackEtityVersion(ByVal entity As IEntity2, ByVal versionName As String)

        Dim reader As System.io.StreamReader
        reader = New System.IO.StreamReader(VersionFileName(entity, versionName))

        Dim xmlFromFile As String = reader.ReadToEnd()
        reader.Close()

        'preserver ParentObject for each child
        entity.ReadXml(xmlFromFile)

    End Sub

When my entity's related collection is empty all is working OK; but when the related GLMoneyWithdrawalDetailItems collection has any item in it the RollbackEtityVersion function would fail with the follwing error:

Module: ReflectPropertyDescriptor Routine: SetValue Message: • Object type cannot be converted to target type. Stack Trace: • at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value) at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.Xml2Entity(XmlNode node, Hashtable processedObjectIDs, ArrayList nodeEntityReferences) at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2.Xml2EntityCollection(XmlNode node, Hashtable processedObjectIDs, ArrayList nodeEntityReferences) at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.Xml2Entity(XmlNode node, Hashtable processedObjectIDs, ArrayList nodeEntityReferences) at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.ReadXml(XmlNode node) at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.ReadXml(String xmlData) at JCL.LLBLHelper.RollbackEtityVersion(IEntity2 entity, String versionName) in D:\Projects\LLBL\JCL\JCL\Helpers.vb:line 86 at JCL.Windows.DataForm.CancelEdit() in D:\Projects\LLBL\JCL\JCL.Windows\DataForm.vb:line 2616

The strange thing is that the same code is working fine on my laptop. I compared the two XML files and found them to be identical... please help ??? frowning

NOTE: my laptop is runnig WinXP sp2 while my development machine is running Windows 2003 server

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 06-Mar-2005 11:48:06   

Could you check the runtime build version on both machines? You can request that in code: Dim build As String = RuntimeLibraryVersion.Build

Frans Bouma | Lead developer LLBLGen Pro