1

I hope someone can help me with this issue.

I have a simple application written in VS2008, .NETCF 3.5, C#. The application has one form and one button on it. The issue is happening on device that supports camera (Motorola MC9590).

The button starts CameraCaptureDialog but on ShowDialog(), it throws "An unknown error".

The code behind "CAMERA" button is:

    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);
    } 
}

And full stack trace:

     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()

Any help is highly appreciated.

Thanks,

d.b
  • 95
  • 2
  • 9
  • Does the normal Microsoft camera application work correctly? – PaulH Mar 23 '14 at 05:08
  • 2
    Try without setting the CameraCaptureDialog properties. Especially StillQuality setting has to be compatible. On other devices there is a list of supported 'quality' settings in registry. If you use an unsupported setting it will throw exception. – josef Mar 23 '14 at 10:04
  • @PaulH Thank you Paul. It seem to be working fine. I haven't used it before but just checked and it is not creating any issue. It is definitely something in the code above but not sure what since that code is exactly what people recommend doing (including MSDN). – d.b Mar 24 '14 at 17:54
  • @josef Thank you Josef. I will try that. Do you know where in registry can I find the predefined quality setting values? – d.b Mar 24 '14 at 17:55
  • I am sorry, bu the reg locations for supported camera resolutions is device (OEM) specific. So there is no general location. – josef Mar 25 '14 at 18:30

0 Answers0