我希望有人可以帮我解决这个问题。
我有一个用VS2008,.NETCF 3.5,C#编写的简单应用程序。该应用程序有一个表单和一个按钮。问题出现在支持摄像头的设备上(Motorola MC9590)。
按钮启动CameraCaptureDialog,但在ShowDialog()上,它会抛出“未知错误”。
“CAMERA”按钮后面的代码是:
private void btnCam_Click(object sender, EventArgs e)
{
string strFileName = "";
try
{
using (CameraCaptureDialog cam = new CameraCaptureDialog())
{
cam.Owner = this;
cam.InitialDirectory = @"\My Documents";
cam.DefaultFileName = @"test.jpg";
cam.Mode = CameraCaptureMode.Still;
cam.StillQuality = CameraCaptureStillQuality.High;
cam.Title = "TESTING";
DialogResult dlg;
dlg = cam.ShowDialog(); //**** THIS IS WHERE IT THROWS ERROR ****
if (dlg == DialogResult.OK)
{
strFileName = cam.FileName;
}
} // end of using
}
catch(Exception ex)
{
MessageBox.Show("Error: " + ex.Message +
" Stack: " + ex.StackTrace);
}
}
完整堆栈跟踪:
at Microsoft.WindowsMobile.Forms.CameraCaptureDialog.LaunchCameraCaptureDialog(IntPtr ptrStruct)
at Microsoft.WindowsMobile.Forms.CameraCaptureDialog.ShowDialog()
at CameraAndSymbolBarcodeTest.Form1.btnCam_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
at System.Windows.Forms.Application.Run(Form fm)
at CameraTest.Program.Main()
非常感谢任何帮助。
谢谢,