Unhandled Exception in c#
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 understand. 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 Op开发者_开发技巧enWebSpiderCS.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]
thank you
This exception tells that when you use Substring function you send startIndex and Length to it. And parameters you sent are invalid because startIndex+Length is more that the length of the whole string.
Just revise your code or check before
if (startIndex+Length < yourString.Length)
Ctrl+Alt+E
in Visual Studio and select Break on Errors
option and you will see the error location.
so ive kind of worked out how this error has occured, basically in the mysql.cs file it is trying to executeSQLQuery where the sub string System.String.Substring (Int32 startIndex, Int32 length) has been set to SQL.Substring(0, 1000) , now there exists a variable in args.cs file which defines the variable length .
the read out on the console says startIndex + length > this.length Parameter name: length
im gussing that this is a generic message and that this.length points to the variable a.length in the args.cs file. any ideas on how to correct the error now?
i dont know if i should paste the files in here as they may be considered quite large. thanks for any help provided
the files can be downloaded from http://sourceforge.net/projects/openwebspider/files/OpenWebSpider%23/v0.1.4.1/OpenWebSpiderCS_v0.1.4.1.zip/download
精彩评论