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 - Unhandled Exception: System.ArgumentOutOfRangeException: startIndex + length > this.length
-
Parameter name: length
-
at System.String.Substring (Int32 startIndex, Int32 length) [0x00000]
-
at OpenWebSpiderCS.mysql.executeSQLQuery (System.String SQL) [0x00000]
-
at OpenWebSpiderCS.db.startIndexThisSite (OpenWebSpiderCS.page p) [0x00000]
-
at OpenWebSpiderCS.ows.startCrawling () [0x00000]
-
at OpenWebSpiderCS.mainClass.Main (System.String[] args) [0x00000]
-
4 5614
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.
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
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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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: ...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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)...
|
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....
|
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
| |