我得到這個奇怪的錯誤 -參數無效ERROR - VB.Net - 爲什麼我得到這個錯誤?
「參數無效」
與圖像時。我製作了許多許多圖像 - 一次最多可達50張。我不清楚這個錯誤可能是什麼。記憶?我在完成計算後處理位圖。任何見解都會有所幫助。謝謝。
Private Async Function TakePhoto(ByVal keyword As String) As task
Await Task.Delay(WaitMs)
'System.Threading.Thread.Sleep(WaitMs)
Try
My.Computer.Audio.Play(Directory.GetCurrentDirectory + "\" + "iphone_camera.wav")
Dim pic = New Bitmap(WebKitBrowser1.Width, WebKitBrowser1.Height)
WebKitBrowser1.DrawToBitmap(pic, New Rectangle(0, 0, pic.Width, pic.Height))
Dim fileName = Directory.GetCurrentDirectory + "\" + "test_ss.bmp"
Dim CropRect As New Rectangle(240, 190, 1000, 2800)
Dim OriginalImage1 = Image.FromFile(fileName)
Dim CropImage1 = New Bitmap(CropRect.Width, CropRect.Height)
Using grp = Graphics.FromImage(CropImage1)
grp.DrawImage(OriginalImage1, New Rectangle(0, 0, CropRect.Width, CropRect.Height), CropRect, GraphicsUnit.Pixel)
OriginalImage1.Dispose()
CropImage1.Save(fileName)
CropImage1.Dispose()
End Using
fileName = Directory.GetCurrentDirectory + "\" + "test_ss.bmp"
CropRect = New Rectangle(0, 0, 1000, 1400)
Dim OriginalImage2 = Image.FromFile(fileName)
Dim CropImage2 = New Bitmap(CropRect.Width, CropRect.Height)
Using grp = Graphics.FromImage(CropImage2)
grp.DrawImage(OriginalImage2, New Rectangle(0, 0, CropRect.Width, CropRect.Height), CropRect, GraphicsUnit.Pixel)
OriginalImage2.Dispose()
'CropImage2.Save(Directory.GetCurrentDirectory + "\" + keyword + "_" + "test_ss_top.bmp")
CropImage2.Save(Directory.GetCurrentDirectory + "\" + "test_ss_top.bmp")
CropImage2.Dispose()
End Using
fileName = Directory.GetCurrentDirectory + "\" + "test_ss.bmp"
CropRect = New Rectangle(0, 1401, 1000, 1330)
Dim OriginalImage3 = Image.FromFile(fileName)
Dim CropImage3 = New Bitmap(CropRect.Width, CropRect.Height)
Using grp = Graphics.FromImage(CropImage3)
grp.DrawImage(OriginalImage3, New Rectangle(0, 0, CropRect.Width, CropRect.Height), CropRect, GraphicsUnit.Pixel)
OriginalImage3.Dispose()
'CropImage3.Save(Directory.GetCurrentDirectory + "\" + keyword + "_" + "test_ss_bottom.bmp")
CropImage3.Save(Directory.GetCurrentDirectory + "\" + "test_ss_bottom.bmp")
CropImage3.Dispose()
End Using
Catch ex As Exception
Dim err = ex.Message
End Try
End Function
你嘗試調試和單步調試代碼到底在哪被拋出的錯誤來縮小? – Nkosi
我可以嘗試,但問題是程序工作了一段時間 - 比如40張左右 - 然後這個錯誤突然出現,所以很難跨過,因爲你永遠不知道錯誤何時出現。有什麼建議麼? – PiE
檢查這個http://stackoverflow.com/a/13914830/5233410 – Nkosi