473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Array Bounds Exception Inside system.xml.dll

Array Bounds Exception inside system.xml.dll. Test data is a dozen GB (available for the asking on CD). Source code follows. Call into system.xml.dll happens at the while statement..

using System
using System.Xml
using System.Collections

// This program reads an ASCII file of XML elements
// The output is a list of unique NODE TYPEs
// For example, <head> produces head in the output
// There is no validation of the XML

namespace xmlReaderAp

/// <summary
/// Summary description for Class1
/// </summary
class Class

/// <summary
/// The main entry point for the application
/// </summary
[STAThread

static void Main(string[] args

int symbolNumber=0
ArrayList arrayList = new ArrayList()
XmlTextReader xmlReader = new XmlTextReader(@"c:\1.xml")
tr

xmlReader.MoveToContent(); // Get beyond the DTD which we don't care abou

catch (Exception e

Console.WriteLine("Exception: " + e.Message); // handle undefined DT

try

while (xmlReader.Read())

symbolNumber++
if (symbolNumber % 100000 == 0
Console.WriteLine(symbolNumber)
switch (xmlReader.NodeType)

case XmlNodeType.Element
// Console.Write("<{0}>", xmlReader.Name)
bool bDoAdd = true
foreach (String memberofArrayList in arrayList
if (memberofArrayList.Equals(xmlReader.Name)

bDoAdd = false
break

if (bDoAdd
arrayList.Add(xmlReader.Name)
break
case XmlNodeType.Text
// Console.Write(xmlReader.Value)
break
case XmlNodeType.CDATA
// Console.Write("<![CDATA[{0}]]>", xmlReader.Value)
break
case XmlNodeType.ProcessingInstruction
// Console.Write("<?{0} {1}?>", xmlReader.Name, xmlReader.Value)
break
case XmlNodeType.Comment
// Console.Write("<!--{0}-->", xmlReader.Value)
break
case XmlNodeType.XmlDeclaration
// Console.Write("<?xml version='1.0'?>")
break
case XmlNodeType.Document
break
case XmlNodeType.DocumentType
// Console.Write("<!DOCTYPE {0} [{1}]", xmlReader.Name, xmlReader.Value)
break
case XmlNodeType.EntityReference
// Console.Write(xmlReader.Name)
break
case XmlNodeType.EndElement
// Console.Write("</{0}>", xmlReader.Name)
break

xmlReader.Close()
foreach (String memberofArrayList in arrayList
Console.WriteLine(memberofArrayList)
Console.WriteLine("This program has terminated.")

catch(Exception e)

xmlReader.Close()
Console.WriteLine("Exception: " + e.Message)
Console.WriteLine(e.StackTrace)
Console.WriteLine(e.Source)
foreach (String memberofArrayList in arrayList
Console.WriteLine(memberofArrayList)
Console.WriteLine("This program has terminated.")
return


Nov 12 '05 #1
4 3830
William McIlroy wrote:
Array Bounds Exception inside system.xml.dll. Test data is a dozen GB (available for the asking on CD). Source code follows. Call into system.xml.dll happens at the while statement...


Dozen GB XML document???? Holy cow! :)
Provide more info please: .NET version, exact exception message along
with full stack trace.

Should note also - the following loop:

foreach (String memberofArrayList in arrayList)
if (memberofArrayList.Equals(xmlReader.Name))

is a way ineffective, you can get huge raise in performance using
Hashtable instead of ArrayList.

--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #2
Exception: Index was outside the bounds of the array
at System.Xml.XmlTextReader.SetElementValues(
at System.Xml.XmlTextReader.ParseElement(
at System.Xml.XmlTextReader.Read(
at xmlReaderApp.Class1.Main(String[] args

A first chance exception of type 'System.IndexOutOfRangeException' occurred in system.xml.dl

Additional information: Index was outside the bounds of the array

1.1.4322 VERSION of .NE

Since I wrote the program for myself, I don't care about performance. It is fast enough for me
You heard correctly: 11 gigabytes. It is generated by a National Institutes of Health conversion program
But thanks for the advice
Originally, the structured data is in ASN.1 format.
Nov 12 '05 #3
William McIlroy wrote:
Exception: Index was outside the bounds of the array.
at System.Xml.XmlTextReader.SetElementValues()
at System.Xml.XmlTextReader.ParseElement()
at System.Xml.XmlTextReader.Read()
at xmlReaderApp.Class1.Main(String[] args)


Apparently 2Gb is the limitation of the XmlTextReader. See
http://groups.google.com/groups?hl=e...A11%26rnum%3D1

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #4
Very well. I'll write my business application in Java.
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Eugene | last post by:
Hello all, I've been trying to figure this out for a few days now, and still have no clue what's going on... I have a few related tables in MS Access (Clients, Cars, Sales), and a datagrid,...
8
by: User | last post by:
Hi, This is very basic, It may be a repost, if so I'm sorry. The problem is that this declaration : Private strMyArray(100) As String will create an array of string with a length of 101,...
4
by: Shawn B. | last post by:
Greets, I am saying int y = 0; byte x; x = new byte; And this work until
6
by: Flip | last post by:
I'm reading the O'Reilly's Progamming C# book and I have a question about array bounds checking. On page 174, near the top, they show an example where c# does indeed to array bounds checking cause...
0
by: scotthutchinson | last post by:
I have a .NET Remoting object hosted in IIS6 on Windows Server 2003 (happens before and after installing SP1) at an endpoint (ASP.NET application virtual folder) named "CompanyXYZReporting". The...
10
by: Antoine | last post by:
I can't work out what is causing this problem. Can anyone suggest what the typical causes beyond the obvious might be? Could you get it with datasets? Maybe I should run in debug mode and test...
4
by: Antoine | last post by:
Herfried and Cor:- I used tracing and actually tracked down the code that was causing the problem most likely. I wonder if you wanted to comment on it. Also I wonder if there is a better way...
125
by: jacob navia | last post by:
We hear very often in this discussion group that bounds checking, or safety tests are too expensive to be used in C. Several researchers of UCSD have published an interesting paper about this...
152
by: vippstar | last post by:
The subject might be misleading. Regardless, is this code valid: #include <stdio.h> void f(double *p, size_t size) { while(size--) printf("%f\n", *p++); } int main(void) { double array = { {...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.