InvalidOperation on CameraCaptureDialog.ShowDialog

L

Lisurc

Hello,

I got the hand over a Windows Mobile 2005 Pocket PC (an Eten M600) and
wanted to try some of the new features coming with the CF .NET 2.0.

But when I played with the CameraCaptureDialog class, an
InvalidOperation was throwed on the ShowDialog() method. At first I
thought I had a problem regarding the framework not being properly
installed on the device, but some other new methods work lie a charm
(POOM, Phone Calls etc.).

I tried different settings before calling ShowDialog(), and, of course,
the device has an integrated Camera but the result is always the same.

I thought all Windows Mobile 2005 certified devices had to support the
new API calls, could it be possible I fell on a device not supporting
it or am I missing something?
 
P

Peter Foot [MVP]

You certainly thought right, all Windows Mobile 5.0 devices with a built in
camera _should_ support the standard APIs for camera capture. Can you post a
code snippet of how you are calling it?

Helpfully the documentation says this about the exception types raised in
ShowDialog:-
System.InvalidOperationException Thrown when an unknown error
occurred.


Is there any other information in the exception's description? an error code
perhaps?

Peter
 
L

Lisurc

Well, the very simple following code snippet is enough to get the
exception to be thrown (C# language):

CameraCaptureDialog dlg = new CameraCaptureDialog();
dlg.ShowDialog();

I then wondered if the built-in camera had some special characteristics
which could not match the default settings. So I tried to set some
properties to specific values (this code is embedded in a click action
for a form button):

CameraCaptureDialog dlg = new CameraCaptureDialog();
dlg.InitialDirectory = @"\Program Files";
dlg.DefaultFileName = @"picture.jpg";
dlg.Title = "Hi there";
dlg.Mode = CameraCaptureMode.Still;
dlg.StillQuality = CameraCaptureStillQuality.Normal;
dlg.Resolution = new Size(320, 200);
dlg.Owner = this;
dlg.ShowDialog();

And result is the same.

Regarding the exception itself, it is catchable in a try block (is is
enough to catch the ShowDialog call) and is indeed a
System.InvalidOperationException one. When spying the variable in
Visual Studio, among several things the Message (_message) property is
set to the popular "An unknown error has occured" and Stacktrace reads:
(french environment where "à" is probably the "at" translation)

à
Microsoft.WindowsMobile.Forms.CameraCaptureDialog.LaunchCameraCaptureDialog()
à Microsoft.WindowsMobile.Forms.CameraCaptureDialog.ShowDialog()
à Test2005.Form1.button1_Click()
à System.Windows.Forms.Control.OnClick()
à System.Windows.Forms.Button.OnClick()
à System.Windows.Forms.ButtonBase.WnProc()
à System.Windows.Forms.Control._InternalWnProc()
à Microsoft.AGL.Forms.EVL.EnterMainLoop()
à System.Windows.Forms.Application.Run()
à Test2005.Form1.Main()

There is also the HResult (_HResult) member set to -2146233079 , but I
have no idea of the meaning of this value.

I pass over the _methodDescs array (10 entries) but if you think it
could give any clues, I may list its content. Sadly, there is no sign
of an error code or magic explicit value saying "Hey, you could have
looked in this place".

-- Lisurc
 
P

Peter Foot [MVP]

Its a pity the code inside ShowDialog doesn't return the HRESULT from the
native SHCameraCapture API call. One way to further diagnose the problem
would be to write a simple native code (C++) app which calls the underlying
SHCameraCapture dialog. Then if you step through with the debugger you can
determine the actual hresult returned and hence possible cause. It may also
be worth checking that you have the latest ROM update for the device as
there have been a few updates since the initial WM5.0 release.

Peter

--
Peter Foot
Windows Embedded MVP
www.peterfoot.net | www.inthehand.com

Well, the very simple following code snippet is enough to get the
exception to be thrown (C# language):

CameraCaptureDialog dlg = new CameraCaptureDialog();
dlg.ShowDialog();

I then wondered if the built-in camera had some special characteristics
which could not match the default settings. So I tried to set some
properties to specific values (this code is embedded in a click action
for a form button):

CameraCaptureDialog dlg = new CameraCaptureDialog();
dlg.InitialDirectory = @"\Program Files";
dlg.DefaultFileName = @"picture.jpg";
dlg.Title = "Hi there";
dlg.Mode = CameraCaptureMode.Still;
dlg.StillQuality = CameraCaptureStillQuality.Normal;
dlg.Resolution = new Size(320, 200);
dlg.Owner = this;
dlg.ShowDialog();

And result is the same.

Regarding the exception itself, it is catchable in a try block (is is
enough to catch the ShowDialog call) and is indeed a
System.InvalidOperationException one. When spying the variable in
Visual Studio, among several things the Message (_message) property is
set to the popular "An unknown error has occured" and Stacktrace reads:
(french environment where "à" is probably the "at" translation)

à
Microsoft.WindowsMobile.Forms.CameraCaptureDialog.LaunchCameraCaptureDialog()
à Microsoft.WindowsMobile.Forms.CameraCaptureDialog.ShowDialog()
à Test2005.Form1.button1_Click()
à System.Windows.Forms.Control.OnClick()
à System.Windows.Forms.Button.OnClick()
à System.Windows.Forms.ButtonBase.WnProc()
à System.Windows.Forms.Control._InternalWnProc()
à Microsoft.AGL.Forms.EVL.EnterMainLoop()
à System.Windows.Forms.Application.Run()
à Test2005.Form1.Main()

There is also the HResult (_HResult) member set to -2146233079 , but I
have no idea of the meaning of this value.

I pass over the _methodDescs array (10 entries) but if you think it
could give any clues, I may list its content. Sadly, there is no sign
of an error code or magic explicit value saying "Hey, you could have
looked in this place".

-- Lisurc
 
L

Lisurc

Just tried to write that simple C++ app using SHCameraCapture, and it
failed too. However, this time the debugger recognizes the HRESULT
value as the error code for E_FAIL (-2147467259 this time).

By the way, E_FAIL is not directly documented as a possible return
value for the SHCameraCapture API call in MSDN, but since it seems to
be the "General Unknown Damn Failure Error Code", I am not that
surprised.

Heading for ROM updates. If any exist and something gets updated with
them, I'll post a message.
Thanks for the answers.

-- Lisurc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top