Vivek Thakur

Chaotically Complex

  Home  |   Contact  |   Syndication    |   Login
  102 Posts | 1 Stories | 317 Comments | 66 Trackbacks

News



Archives

ASP.NET Ventures

While debugging a SmartPhone application based on Windows Mobile 5 in VS 2005, I frequently noticed this error:

A first chance exception of type 'Microsoft.WindowsMobile.Utilities.Registry.RegistryException' occurred in Microsoft.WindowsMobile.Utilities.dll

Now there were two questions:

1. What is a "first chance exception"?

2. I could not find Microsoft.WindowsMobile.Utilities dll anywhere. From where is this error coming up?

Regarding issue #1, here is nice blog entry which explains such excpetions in detail:

http://blogs.msdn.com/davidklinems/archive/2005/07/12/438061.aspx

Cool..isn't it? Coming to issue #2 this post suggests that Microsoft.WindowsMobile.Utilities dll is present in WM 5 devices only (in the ROM) as well in the emulators. The exception was thrown after this line in my code:

      if (OutGoingNumber.CurrentValue != null)

Now, I had defined OutGoingNumber as:

private SystemState OutGoingNumber;

OutGoingNumber = new SystemState(SystemProperty.PhoneTalkingCallerNumber);

In the PhoneCallCalling event handler, the outgoing number was picked up by this SystemState property when ever I dialled any number the first time, but this event fires multiple times (as the state changes whenever I hang up/dial a number within this event handler) and the next time the outgoing number is returned null. Even when I have handled the null condition, after passing through the "if" the emulator throws this Registry error. This may be due to the fact that I am setting outgoing number as PhoneTalkingCallerNumber, which infact get's the currently connected phone call's number. I used PhoneTalkingCallerNumber to capture the outgoing number as there was no other way to trap the dialled phone number.

To fix this, in the PhoneCallCalling event handler, I used this code:

void phoneCallCalling_Changed(object sender, ChangeEventArgs args)
{
 
try
  
{
 
     if (SystemState.PhoneCallCalling)
     
{  if(outgoingnumber.value != null)
                 (...code........
}
    }
}

This ensured that the outgoing number was accessed only when the phone was in the Calling state, and hence I would not get the error.

Another thing which threw me off track was the use of PhoneTalkingCallerNumber property to capture the dialled number (uotgoingnumber variable in my example). MSDN documentation states that:

PhoneTalkingCallerNumber : Gets the currently connected caller's phone number.

Now when I am dialling a number, I am not "connected" to it as yet and I am the one who is actually calling someone (the dialled number contact), so will this property return my number? I think this documentation is confusing as I am able to capture the dialled number using this property as shown in the example above.

 

posted on Thursday, December 28, 2006 11:40 PM