大家好。
我正在开发一个安装在运行 Windows Mobile 6.5 的设备上的软件。一方面是正确使用设备的相机。在我的情况下,我想使用 CameraCaptureDialog 如下:
Dim cameraCaptureDialog As New CameraCaptureDialog()
cameraCaptureDialog.Owner = Me
cameraCaptureDialog.Mode = CameraCaptureMode.Still
If cameraCaptureDialog.ShowDialog() = DialogResult.OK AndAlso cameraCaptureDialog.FileName.Length > 0 Then
Dim sFileNameExt As String = ""
Dim sFileDir As String = ""
Dim sPicsDir As String = ""
Dim sFileSource As String = ""
sFileSource = Path.GetFullPath(cameraCaptureDialog.FileName)
sFileDir = Path.GetDirectoryName(cameraCaptureDialog.FileName)
sFileDir = Path.GetPathRoot(cameraCaptureDialog.FileName)
sFileNameExt = Path.GetExtension(cameraCaptureDialog.FileName)
Dim fs As New FileStream(sFileSource, FileMode.OpenOrCreate, FileAccess.Read)
Dim ImgArtikel(CType(fs.Length, Int32)) As Byte
fs.Read(ImgArtikel, 0, CType(fs.Length, Int32))
fs.Close()
functions.ConnectLocalDB(functions.localconn)
Dim cmd As SqlCeCommand = functions.localconn.CreateCommand()
cmd.CommandText = "UPDATE table SET img_Photo=@imgArt " 'assign the newly made image to db-entry
cmd.Parameters.Add("@imgArt", SqlDbType.Image)
cmd.Parameters("@imgArt").Value = ImgArtikel
cmd.ExecuteNonQuery()
cmd.Dispose()
If File.Exists(sFileSource) Then File.Delete(sFileSource) 'delete photo after updating db
End If
cameraCaptureDialog.Dispose()
这第一次工作正常(在模拟器和设备上),但是当我启动相同的事件时,我的软件崩溃了。调试时我没有遇到异常,它只是在 ShowDialog() (第四行)崩溃。
有谁知道这里有什么问题?