Using Microsoft.Phone.Tasks in the Emulator

The Windows Phone 7 emulator is very limited compared with the real phones so there are no built in applications other than Internet Explorer. This can make it difficult to test some of the APIs which interact with data on the device. Luckily there is a way to load contact data onto the emulator which allows you to use these tasks as if you were working against real contacts from your Exchange server or wherever. The trick to this is that the system supports the vCard standard which allows you to attach contact items to emails or via the web. Internet Explorer understands vCard files and provides the option to save them in the People list on the phone. For example you can browse to to see how this process works. From within your application you can also use the WebBrowserTask (AFAIK it does not work when you host the WebBrowser control in your own app).


Tap the contact image to open in a new contact page:-


You can make changes to the contact and then tap the disk icon to save.

When you close the emulator the contents are not persisted so you’ll have to repeat this each time you launch the emulator. Unfortunately this doesn’t appear to support vCard files containing multiple entries. However having just one entry in there allows you to test your app flow where you have a contact picking scenario.

If you want to test the PhotoChooserTask you can also import images to the emulator. Simply visit any website and tap and hold over an image – select “save picture” from the context menu which pops up. These are placed in a “Saved Pictures” folder.

The PhoneCallTask and SmsComposeTask work as expected (like the Windows Mobile emulators there is a fake mobile network). The EmailComposeTask does not work as there is no account on the emulator and no way to add one. When you launch it you’ll get an error popup.

By Peter Foot

Microsoft Windows Development MVP