簡體   English   中英

C#中未處理的異常

[英]Unhandled Exception in c#

我目前正在嘗試通過終端運行網絡搜尋器。 它編譯良好,並且調試未找到任何錯誤,但是我收到以下我不理解的錯誤。 任何關於如何擺脫這個錯誤的想法將不勝感激

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] 

謝謝

此異常告訴您,當您使用Substring函數時,會向其發送startIndex和Length。 您發送的參數無效,因為startIndex + Length大於整個字符串的長度。

只需修改您的代碼或先檢查

if (startIndex+Length < yourString.Length)

在Visual Studio中Ctrl+Alt+E並選擇Break on Errors選項,您將看到錯誤位置。

因此,我弄清了如何發生此錯誤,基本上是在mysql.cs文件中,它試圖執行SQLQuery,其中子字符串System.String.Substring(Int32 startIndex,Int32長度)已設置為SQL.Substring(0, 1000),現在args.cs文件中存在一個變量,該變量定義了變量length。

控制台上的讀數顯示startIndex + length> this.length參數名稱:length

我懷疑這是一條通用消息,並且this.length指向args.cs文件中的變量a.length。 關於如何立即糾正錯誤的任何想法?

我不知道是否應該將文件粘貼在這里,因為它們可能被認為很大。 感謝您提供的任何幫助

可以從http://sourceforge.net/projects/openwebspider/files/OpenWebSpider%23/v0.1.4.1/OpenWebSpiderCS_v0.1.4.1.zip/download下載文件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM