473,320 Members | 1,876 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,320 software developers and data experts.

Unhandled Exception. System.ArgumentOutOfRangeException

i am currently trying to run a web crawler through the terminal. it compiles fine and the debug does not find any errors, however i get the following error which i do not under stand.
any ideas on how to get rid of this error would be much appreciated

Expand|Select|Wrap|Line Numbers
  1. Unhandled Exception: System.ArgumentOutOfRangeException: startIndex + length > this.length
  2. Parameter name: length
  3.   at System.String.Substring (Int32 startIndex, Int32 length) [0x00000]
  4.   at OpenWebSpiderCS.mysql.executeSQLQuery (System.String SQL) [0x00000]
  5.   at OpenWebSpiderCS.db.startIndexThisSite (OpenWebSpiderCS.page p) [0x00000]
  6.   at OpenWebSpiderCS.ows.startCrawling () [0x00000]
  7.   at OpenWebSpiderCS.mainClass.Main (System.String[] args) [0x00000]
  8.  
Apr 11 '10 #1
4 5614
tlhintoq
3,525 Expert 2GB
Read error messages like this backwards.
The first line is the most recent...
it was caused by the line below it...
which came from the line below it.
The error message is a history.

If we read it from the bottom, upward... You should see the very process your program follows, right up to line that fails.

mainClass started
startCrawling()
startIndexThisSite
String.Substring (startIndex, length)

Then your error...
Unhandled Exception: System.ArgumentOutOfRangeException: startIndex + length > this.length
Parameter name: length

So you have a function that is working the substring of some variable starting at "startIndex" for "this.Length" number of characters.

The error is telling you that parameter "length" isn't valid - and that you have not correctly handled that exception.

So if you fed in a string 20 characters long... and your startIndex is 10 and you try to go for a length of 20 FROM THAT START INDEX you would end at character 30. Well you can't end at character 30 out of 20, can you?

Now that you have an explanation, read the error again. Does it make more sense?

System.ArgumentOutOfRangeException: startIndex + length > this.length
Parameter name: length

startIndex + length is greater than this.length
That number is out of the range of characters available to work with.
Apr 11 '10 #2
thank you for your explanation, the code is from an open source project so i don't know the code intimately. however from your explanation i'm guessing that this.length in the "args" file needs to be made larger. the substring on line 4 of the read out is SQL.substring(0, 1000). does this mean i have to change this.length to be equal or greater to 1000?

all your help is much appreciated.

thank you
Apr 12 '10 #3
tlhintoq
3,525 Expert 2GB
I know nothing about the open source project you got the code from.

Personally I try to avoid just guessing and thrashing about and making changes all whilly nilly in the hopes I get lucky. You might make a change that solves it in your test environment but next will can still fail in the real world.

I think you should make an effort to actually understand the code and make meaningful *improvements*, not just changes.

Since this is an open source project, there should be many people working on it. It might be best to ask others that contributed to explain the code to you so you better understand it.
Apr 12 '10 #4
jkmyoung
2,057 Expert 2GB
The length is too big, not too small.

Basically you've got a string, say "String".
If you ask for -> you get
substring(0,3) -> "Str"
substring(3,3) -> "ing"
substring(1,4) -> "trin"
substring(3, 5) -> ERROR.

Are you sure you're using the right type of substring function?
This code appears to use the type of substring function like this:
substring(startIndex, length)
whereas other substring functions may be written like this:
substring(startIndex, endIndex).

To convert it properly, you want:
substring(startIndex, endIndex - startIndex)
assuming this is your error.
Apr 13 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Rafael | last post by:
Hi, I hope I can find some help for this problem IDE: Visual Studio.NET 2003 Developer Editio Language: C# Problem: "An unhandled exception of type 'System.NullReferenceException' occurred in...
3
by: Professor Frink | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
2
by: Aron Henning | last post by:
I have a ListView that contains the subfoldes of a local drive. Whan i click on a subfolder the listbox should display the subfolders of this folder instead. the funktion is as follows: private...
4
by: Craig831 | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
7
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote...
5
by: Lucvdv | last post by:
Can someone explain why this code pops up a messagebox saying the ThreadAbortException wasn't handled? The first exception is reported only in the debug pane, as expected. The second (caused by...
0
by: Colmeister | last post by:
I recently read Jason Clark's excellent article on Unhandled Exceptions (http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx) and have attempted to incorporate the features he talks...
1
by: SQLJunkie | last post by:
Hi, I have installed SQL 2005 RTM on a new server and I keep getting this error (described below) quite frequently. Was wondering if anyone has a clue on what's happening here. I tried googling...
0
by: randy.buchholz | last post by:
I am trying to trap the following error. I have tried to catch it on page load and every event on the data source and dd. No luck. I'm forcing the error by setting the dd.text to an invalid value...
6
by: sinhzun | last post by:
Hi everybody, I have a trouble with ArgumentOutOfRangeException. When I type a French word in an AutoCompleteComboBox then submit it to add new record to database, the combo box throw an exception: ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.