【发布时间】:2016-08-20 10:55:33
【问题描述】:
试图读取或写入受保护的内存。这通常是一个 指示其他内存已损坏。
这是我将图像设置为我的图片框后的错误。它工作正常,但后来错误只是弹出。
这是我的代码。
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Try
Dim cap As New Capture() 'first line
PictureBox1.Image = cap.QueryFrame.ToBitmap 'this line AccessViolationException
Catch ex As Exception
Timer1.Stop()
MsgBox("CAMERA ERROR " & ex.Message)
End Try
End Sub
Private Sub MetroTile1_Click(sender As Object, e As EventArgs) Handles MetroTile1.Click
Try
Dim cap As New Capture() 'first line
Select Case MetroTile1.Text
Case "Capture"
Timer1.Start()
MetroTile1.Text = "OK"
Case "OK"
Timer1.Stop()
frmStudentAddEdit.picImage.Image = PictureBox1.Image
MetroTile1.Text = "Capture"
Me.Close()
End Select
Catch ex As Exception
Timer1.Stop()
End Try
End Sub
cap.QueryFrame.ToBitmap 是 AccessViolationException was unhandled 错误。
我该如何解决这个问题?是什么导致了这个错误?请帮忙。
【问题讨论】:
-
我以前没有使用过这个库,但我很惊讶你每次计时器滴答时都会创建一个新的 Capture。查阅示例并检查是否正确,并确保在完成位图后处理它们
-
一旦我从 cam 捕获图像后如何处理位图。抱歉,vb.net 还是硬件方面的新手。