Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. (VS2008 - VB.Net - Compact Framework) DataSet.ReadXml metod fails

(VS2008 - VB.Net - Compact Framework) DataSet.ReadXml metod fails

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpcsharphardwarexml
18 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S steve_9496613

    Thanks Eddy. The path is right. When I go step by step with the debugger everything just stop at the line that read the XML. Today I finnaly get an error message in the device:

    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)
    ...

    Now I know the reason (I think...) but not the solution... Any idea? Thanks

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #4

    A StackOverflowException means that your process has run out of local memory. You can try increasing the stack size or request heap space to hold whatever data is causing the overflow.

    S 1 Reply Last reply
    0
    • S steve_9496613

      Thanks Eddy. The path is right. When I go step by step with the debugger everything just stop at the line that read the XML. Today I finnaly get an error message in the device:

      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)
      ...

      Now I know the reason (I think...) but not the solution... Any idea? Thanks

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #5

      To build on Richards' answer, might help to make the files smaller; cut them in chuncks before reading them. I assume you'll be importing them into a database?

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

      S 1 Reply Last reply
      0
      • L Lost User

        A StackOverflowException means that your process has run out of local memory. You can try increasing the stack size or request heap space to hold whatever data is causing the overflow.

        S Offline
        S Offline
        steve_9496613
        wrote on last edited by
        #6

        Thanks Richard. How can I increase the stack size? I use Visual Studio 2008 and this is a smart device VB.net project. I don't find any specific setting in the project properties

        L 1 Reply Last reply
        0
        • S steve_9496613

          Thanks Richard. How can I increase the stack size? I use Visual Studio 2008 and this is a smart device VB.net project. I don't find any specific setting in the project properties

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #7

          I am not a VB expert so not sure what you would need to do. I guess Google is the place to look. But in reality, this exception is a warning that your application needs reworking in some way.

          S 1 Reply Last reply
          0
          • L Lost User

            To build on Richards' answer, might help to make the files smaller; cut them in chuncks before reading them. I assume you'll be importing them into a database?

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

            S Offline
            S Offline
            steve_9496613
            wrote on last edited by
            #8

            Hi Eddy. These files are created by the application and contain user programming. They can be larger or smaller depending on what the user does. When the user changes something, the file is updated. While the application is running, there is no problem. When the application is closed and restarted, settings are loaded from the file and here is the crash. I load the XML file in a DataSet because I can read all with a line of code with ReadXml and then I copy the DataSet content in the different internal variables and structures; I don't use a real database. To limit the file size and use more than one if one file is not enough could be a solution. If ReadXml works fine in a desktop environment with full .NET, perhaps there is a bug in the .NET Compact Framework version of this function?

            L 1 Reply Last reply
            0
            • S steve_9496613

              Hi Eddy. These files are created by the application and contain user programming. They can be larger or smaller depending on what the user does. When the user changes something, the file is updated. While the application is running, there is no problem. When the application is closed and restarted, settings are loaded from the file and here is the crash. I load the XML file in a DataSet because I can read all with a line of code with ReadXml and then I copy the DataSet content in the different internal variables and structures; I don't use a real database. To limit the file size and use more than one if one file is not enough could be a solution. If ReadXml works fine in a desktop environment with full .NET, perhaps there is a bug in the .NET Compact Framework version of this function?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #9

              steve_9496613 wrote:

              I load the XML file in a DataSet because I can read all with a line of code with ReadXml and then I copy the DataSet content in the different internal variables and structures; I don't use a real database.

              You are using an export-format as a datastore; use a real database and the problem is gone.

              steve_9496613 wrote:

              If ReadXml works fine in a desktop environment with full .NET, perhaps there is a bug in the .NET Compact Framework version of this function?

              Sure, maybe. Maybe there's some difference between the frameworks, simply because a device isn't as powerfull as a real desktop, with more limitations.

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

              S 1 Reply Last reply
              0
              • L Lost User

                steve_9496613 wrote:

                I load the XML file in a DataSet because I can read all with a line of code with ReadXml and then I copy the DataSet content in the different internal variables and structures; I don't use a real database.

                You are using an export-format as a datastore; use a real database and the problem is gone.

                steve_9496613 wrote:

                If ReadXml works fine in a desktop environment with full .NET, perhaps there is a bug in the .NET Compact Framework version of this function?

                Sure, maybe. Maybe there's some difference between the frameworks, simply because a device isn't as powerfull as a real desktop, with more limitations.

                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

                S Offline
                S Offline
                steve_9496613
                wrote on last edited by
                #10

                Eddy Vluggen wrote:

                You are using an export-format as a datastore; use a real database and the problem is gone.

                You're right, I didn't use a real database because of my lack of knowledge about databases.

                L 1 Reply Last reply
                0
                • L Lost User

                  I am not a VB expert so not sure what you would need to do. I guess Google is the place to look. But in reality, this exception is a warning that your application needs reworking in some way.

                  S Offline
                  S Offline
                  steve_9496613
                  wrote on last edited by
                  #11

                  Hi Richard, surely a StackOverflowException means something bad, for this reason I tried to reproduce the problem with few clean lines of code. I managed to replicate the problem just with a Form, a Button and the code I posted. This does not mean that the complete application would not benefit from a reworking (...) but it seems to me that in this situation the problem is in a single line of code. Probably, as Eddy suggests, I should use another way to store and read the application settings.

                  L 1 Reply Last reply
                  0
                  • S steve_9496613

                    Hi Richard, surely a StackOverflowException means something bad, for this reason I tried to reproduce the problem with few clean lines of code. I managed to replicate the problem just with a Form, a Button and the code I posted. This does not mean that the complete application would not benefit from a reworking (...) but it seems to me that in this situation the problem is in a single line of code. Probably, as Eddy suggests, I should use another way to store and read the application settings.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #12

                    steve_9496613 wrote:

                    surely a StackOverflowException means something bad

                    Yes, as I already explained it means you have used up all your local memory (stack space). If that is because you are reading huge amounts of data then that is the area that needs investigation. If that is not the reason (which is also possible) then more debugging may be required. In either case the only way to be sure is to use the debugger to see what is happening inside the application under real load.

                    S 1 Reply Last reply
                    0
                    • S steve_9496613

                      Eddy Vluggen wrote:

                      You are using an export-format as a datastore; use a real database and the problem is gone.

                      You're right, I didn't use a real database because of my lack of knowledge about databases.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #13

                      steve_9496613 wrote:

                      You're right, I didn't use a real database because of my lack of knowledge about databases.

                      Take your time and give it a try; it will not only benefit you in this project, but all the projects to come. If stuck, simply post the code here :) I'd recommend SQLite, since you don't require a dedicated server or multi-user access. It's free, small and there's the benefit that you can copy the db to your desktop and edit its contents there.

                      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

                      S 1 Reply Last reply
                      0
                      • L Lost User

                        steve_9496613 wrote:

                        You're right, I didn't use a real database because of my lack of knowledge about databases.

                        Take your time and give it a try; it will not only benefit you in this project, but all the projects to come. If stuck, simply post the code here :) I'd recommend SQLite, since you don't require a dedicated server or multi-user access. It's free, small and there's the benefit that you can copy the db to your desktop and edit its contents there.

                        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

                        S Offline
                        S Offline
                        steve_9496613
                        wrote on last edited by
                        #14

                        Thanks for your advice Eddy, I'll give it a try. I have already tried SQLite in C++ (Embarcadero C++Builder) but I was not really satisfied from what I managed to do... I see that here there are some articles as "Using SQLite in C#/VB.Net" that seems to be a good point to start.

                        L 1 Reply Last reply
                        0
                        • S steve_9496613

                          Thanks for your advice Eddy, I'll give it a try. I have already tried SQLite in C++ (Embarcadero C++Builder) but I was not really satisfied from what I managed to do... I see that here there are some articles as "Using SQLite in C#/VB.Net" that seems to be a good point to start.

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #15

                          You're welcome :)

                          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

                          1 Reply Last reply
                          0
                          • L Lost User

                            steve_9496613 wrote:

                            surely a StackOverflowException means something bad

                            Yes, as I already explained it means you have used up all your local memory (stack space). If that is because you are reading huge amounts of data then that is the area that needs investigation. If that is not the reason (which is also possible) then more debugging may be required. In either case the only way to be sure is to use the debugger to see what is happening inside the application under real load.

                            S Offline
                            S Offline
                            steve_9496613
                            wrote on last edited by
                            #16

                            Thank you Richard. I'll try to dig deeper to find the reason because this is a loose cannon in my code.

                            L 1 Reply Last reply
                            0
                            • S steve_9496613

                              Thank you Richard. I'll try to dig deeper to find the reason because this is a loose cannon in my code.

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #17

                              It may just be that in an embedded/compact framework you do not have enough physical memory to provide the space that you would expect in a larger system.

                              1 Reply Last reply
                              0
                              • S steve_9496613

                                Hello, in my application taht runs in Windows Embedded Compact 7 OS (with Compact Framework 3.5) I have a problem reading a xml file with DataSet.ReadXml. I have made a little test to reproduce the problem:

                                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)  'j = 3 = XmlReadMode.InferSchema
                                
                                  xr.Close()
                                  fs.Close()
                                
                                Catch ex As Exception
                                  MessageBox.Show(ex.ToString)
                                End Try
                                

                                End Sub

                                I have two test file: default_19.prg and default_20.prg. The first is a little shorter than the second and it is read without problem, the second fails without raising an exception (at least an exception that I can catch). I don't know if it is a file dimension problem or something else. The two files are quite long and I apologize for this but I post them here otherwise who could help me? default_19.prg

                                False
                                4:00:00 PM
                                2
                                1
                                

                                1
                                zona 1
                                1
                                2
                                0
                                1

                                0
                                12:00:00 PM

                                6:00:00 AM
                                6:15:00 AM
                                12:15:00 AM
                                0
                                50
                                1
                                1

                                6:15:00 AM
                                5:45:00 PM
                                11:30:00 AM
                                50
                                50
                                2
                                0

                                5:45:00 PM
                                6:00:00 PM
                                12:15:00 AM
                                50
                                5
                                3
                                2

                                M Offline
                                M Offline
                                Member_14649247
                                wrote on last edited by
                                #18

                                For online Course on .net Framework 4.5 using C# , Please Click here.

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups