Phone API in OpenNETCF

L

Lloyd Dupont

I'm trying to use the OpenNETCF.Phone.Phone class
and, to be exact, the Phone.MakeCall(string destination) static method.
(which I donwload to day from the website)

I get a MissingMethodException when the code is trying to call
PhoneMakeCall(ref mci)

On one hand I can't find (with the file explorer) the phone.dll on my PPC,
so I'm not really surprised to have an error.
But I'm surprised it's a MissingMethodException and there is no user
friendly erro message.
what about using System.ComponentModel.Win32Exception ?!

BTW is it normal I don't have a phone.dll ?
could it be it's hidden (as some DLL are) ?
so it explain it's not a FileNotFoundException, but why a
MissingMethodException then ???
 
T

Trollpower

Just an Idea, but i think this happens because the PhoneAPI gets
P/Invoked. So there is no real userfriendly Exceptionhandling. Since
P/Invoked Stuff is not managed, as far as i know, so you cant expect
to get an reasonable exeption message. If a Method cant be found in a
DLL, for example the Parameters are wrong, it allways throws a
MissingMethodException

One thing you can do to know if your PPC supports Phonecalls is to do
a File.Exisits on the PhoneAPI. if it exisits you simple know, that
you cant use it. Additionally you can the throw a reasonable Exception
with an userfriendly message.

Due to the problem that you say in a P/Invoke which method in which
DLL has to be taken, and the whole stuff is not managed, the framework
takes the DLL as given, and throws a MissingMethodException, since it
can find the given method in the DLL.

Just my two cents, but maybe its the solution

Greetings

Jens
 
P

Paul G. Tobey [eMVP]

What sort of PPC do you have exactly? The Phone Edition or not? I don't
think it will make a call if it's not a phone edition or SmartPhone.

"MissingMethodException" indicates that the function that you attempted to
call could not be found. It might happen because there was no DLL, because
the DLL did not contain the desired call, etc. A FileNotFoundException in
this context would not be the right thing to do. Imagine that the call you
were trying to make was something like DeleteFile(). A
FileNotFoundException would lead you all over the place trying to figure out
why the file you wanted to delete was 'not found', when in fact the problem
was that you incorrectly declared the P/Invoke.

Paul T.
 
P

Peter Foot [MVP]

Agreed that there is no additional exception thrown other than that thrown
when the P/Invoke fails, but this is still descriptive of the fault. Adding
a message to the exception may help, along with detailing the reason for the
exception in the documentation of course. The Phone library is still under
development and while I intend to add exception details to the
documentation, I'm not sure any other exception would be more appropriate
than MissingMethodException.

The entire Phone library is specific to devices running either Pocket PC
Phone Edition or Smartphone 2003. What I believe is required therefore is
some method to first check programmatically if the device is "phone enabled"
before calling these functions (or just add exception handling to catch the
MissingMethodException). Because this library is tied to the Microsoft Phone
APIs it is not supported on devices which while having phone functionality
do not implement it through the Phone Edition or Smartphone platform - for
example the iPaq GPRS jacket.

Peter
 

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