Good news/bad news about WP7 Task objects
Apr
7
Written by:
Wednesday, April 07, 2010 9:26 PM
Tonight I learned about 10 very cool "Task" objects you can use with your WP7, but you cannot use them with the emulator. Read on for more details.
Tonight, I ran into my first instance I really, Really, REALLY want a WP7! The real deal! The actual hardware, and actual phone I can plug in with USB, something I can actually touch to try STUFF out on. Device hardware I can deploy my app to in order to test it. Why? Well, tonight I read about ten very cool and potentially mind blowing "Task" objects (thank you Rudi Grobler for the info!) which in three lines of code, namely things like:
- Bing maps
- Camera capture
- Email address chooser
- Opening the Marketplace
- Opening up music/vids
- Making a call
- Saving an email address
- Bing searches
- Composing SMS messages
- Accessing a web browser
Yup, in three lines of code you can open up Bing Search
SearchTask search = new SearchTask();
search.SearchQuery = "Privasoft";
search.Show();
Launching the Marketplace is even easier with ONE line of code
MarketplaceLauncher.Show(MarketplaceContent.Applications, MarketplaceOperation.Open);
The only problem is, when I do these things, I get a COMException error pointing to some cryptic file now found errors. Uhm.......I would have thought this kind of thing should have been detected BEFORE I can get to the point of running the actual code in the emulator, no? Below, you'll see the lines of code which will generate the error and the actual screen cap of the COMException I got.

I Googled the exact error and an MDSN link came up, looks like a good candidate right? hhhmmmmm uuuuuhhhhh......hhhmmmmmm

Floppy disk? Really? I haven't owned a computer with a FLOPPY disk for over TEN YEARS!!!!!!!!!! WTF? Me thinks THAT doc is a bit stale?
I haven't tried ALL of the "Task" objects but the WebBrowser is the only one that works so far. Now that one is VERY cool, you get all the cool things you'd expect in your browser including automagical Back button support without any NavgationService.Navigate() stuff. The code for doing this magic is exceptionally simple!
WebBrowserTask browser = new WebBrowserTask();
browser.URL = "http://www.pchenry.com";
browser.Show();
And then you'll get a browser "in your app" (or more accurately, FROM your app) for free! No including some Microsoft.Phone.Controls.WebBrowser Reference, no extra WebBrowser user control on a page, just three lines of code. Simple eh?

Now, I know the COMException thing is just a fluke, well, I HOPE it's a fluke and it'll just get fixed soon enough. Until then, steer clear of them until you get a phone (which I really Really REALLY hope is SOOOOOOOOOOOOOOON!!!!!!!!!!!!!), until then, it's time to grab a coffee and get coding!
Resources:
Rudi Grobler: And it can make phone calls...
MSDN: Error Message