none
DataSet.ReadXml method fails with StackOverflowException RRS feed

  • Question

  • Hello everybody.

    I have a problem in my application when I try to load a XML file in a DataSet using the ReadXml method.

    I have made a little test app with a form, a button and this code:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Dim dati As DataSet = New DataSet("Programmazione")
      Dim fname As String
      Dim j As Int32
    
      Try
    
        fname = "\Program Files\SmartDeviceProject1\default_19.prg"   'this works
        'fname = "\Program Files\SmartDeviceProject1\default_20.prg"   'this doesn't work
        Dim fs As New FileStream(fname, FileMode.Open, FileAccess.Read)
        Dim xr As XmlReader = System.Xml.XmlReader.Create(fs)
    
        dati.Clear()
        j = dati.ReadXml(xr)  'EXCEPTION (when it works: j = 3 = XmlReadMode.InferSchema) 
    
        xr.Close()
        fs.Close()
    
      Catch ex As Exception
        MessageBox.Show(ex.ToString)
      End Try
    
    End Sub

    The two test file are different in size, with the more little one (default_19.prg) there is no problem, with the bigger one (default_20.prg) the application crashes usually without giving any information but once I get the error message:

    System.StackOverflowException: StackOverflowException
      at System.Xml.Schema.SequenceNode.ConstructPos(BitSet firstpos, BitSet lastpos, Bitset[] followpos)
      at System.Xml.Schema.SequenceNode.ConstructPos(BitSet firstpos, BitSet lastpos, Bitset[] followpos)
      at System.Xml.Schema.SequenceNode.ConstructPos(BitSet firstpos, BitSet lastpos, Bitset[] followpos)
      ...

    The application runs on a device with Windows Embedded Compact 7 OS, I use Visual Studio 2008, VB.Net.

    If I run the same application in desktop environment, ReadXml doesn't fail.

    I don't understand if in the Compact Framework there is some kind of limitation, as the nodes number in the XML file to be read, or it is a problem related to the device on which I run the application.

    Furthermore, how can I increase the stack size?

    Anyone can help me?
    Thanks in advance.

    Here are the two file:

    sample files



    • Edited by TheEngenius Friday, November 22, 2019 3:00 PM
    Friday, November 8, 2019 10:39 AM