Tuesday, July 10, 2012

Handling Errors in Windows Phone

When I published my first phone application, Basic Jacks or Better Video Poker, I put little to no error handling within my app because I never encountered any while testing it.  I probably logged over 50+ hours of playing it and never encountered any crashes.  But on the Microsoft App Hub site, it shows my app is crashing 1-2 times a week:


The stack trace pointed to the AdControl which points me in the direction of that this is a Microsoft problem and not related to my source code. 

Here is a breakdown on adding a catch all error handling to your windows phone app using C#.
  1. First create a ErrorPage.xaml page to your project.
  2. Add a Textblock control "ErrorText" that will store your error message:

    <TextBlock x:Name="ErrorText" Style="{StaticResource PhoneTextSmallStyle}" TextWrapping="Wrap" Text="error will go here" Margin="12,20,12,0" />

  3. Modify the Header field and add any other elements to the page to make it user friendly:
  4. Now open the code behind page (ErrorPage.xaml.cs) and add the following code:

           public static Exception Exception;

            protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                ErrorText.Text = Exception.Message;
            }

  5. Next add code to the App.xaml.cs file in the Application_UnhandledException procedure:

                e.Handled = true;

                ErrorPage.Exception = e.ExceptionObject;

                (RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Source =              new Uri("/ErrorPage.xaml", UriKind.Relative);

  6. Add the same code to the RootFrame_NavigationFailed procedure using the e.Exception object instead of e.ExceptionObject:

                e.Handled = true;

                ErrorPage.Exception = e.Exception;

                (RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Source =              new Uri("/ErrorPage.xaml"UriKind.Relative);

  7. Next add a button and code that you know will fail. Like divide by 0 or navigate to a page that does not exists.
Just some footnotes. 
  • I added the Report Error button that will send the Stack Trace back to me.  Its probably not needed because the Stack Trace is appearing in the reports.  
  • The Back button will navigate the user back to the start page. The reason why to manually pushed the user is because the Back button the phone is what is causing the AdControl error.  This gives a user the ability to stay in the app otherwise they would have to click the Window button then reopen the application.

Monday, July 2, 2012

AOL vs Facebook lessons

I was channel surfing the other day and a very old PBS documentary came up of AOL (previously known as America Online, Inc.) back in the late 80s.  It interviewed Steve Case and talked about the revolution of being interconnected in a community online.  For those of you that do not know, AOL had the largest wide area network of users with over 12 million users at its peak all interconnected through its online portal. As I was watching this documentary, I couldn't help but compare their rise to that of Facebook.  AOL was a giant community that everyone could intercommunicate with via email, chat, or instant messaging.

Why did AOL fail where Facebook succeeded?

Lets run down some basic comparisons of the services that they provide:

Profile Information
AOL really dropped the ball on this.  They had a profile page that could add very basic information like name, age, location, and hobbies.  This page was OPTIONAL and most people did not user their real information.  There was no way to add a picture of yourself.  When someone wanted a picture of you, they had to ask you and then you emailed a profile picture of yourself to them.  Granted, this was the days before digital cameras, so most people did not have digital picture of themselves.  Imagine if AOL created a profile like Facebook:

  • What is on your mind?
  • Friend lists
  • Photo albums
  • links to hobby pages instead of just text descriptions
  • A birthday field
  • Timeline
  • Like buttons
The only way to personalize yourself was to create a webpage, which required knowledge of HTML.  AOL gave everyone 10 Megabytes (laughable!) of space to create a public website.  There was no way to add a link to your personal page on your AOL profile!  AOL prevented embedding an html address into your profile. 


Online Friends
AOL had a very weak connection ability.  You could flag friends that you wanted to monitor when they came online, but there is no way to check their status or see what they were up to unless you just emailed them or chatted with them.  Other than directly asking them, there was no way to keep tabs on people like you can on Facebook.


Privacy
Facebook is all about making yourself public, but at the same token, it gives you incredible fine grain control over what you want to make private and to whom has access to your profile.  AOL had none of this, your email and profile where 100% public, that is why most people put fake information in them.  AOL added some safeguards for parental control, but there was nothing for the average user to allow privacy.



Email
My email account with AOL was my first public email address and it was exciting to have and to share with friends and relatives on a new way to communicate with me.  But AOL sold their email list to spammers and it very quickly became a nuisance to have and I received over 50 spams a day.  Facebook has given everyone a Facebook.com domain email account recently, but it is primarily to used to only email other Facebook users and I have yet to receive one spam email to this account.

Advertising
Facebook utilizes a very simple way of advertising to its users by targeted ads on the right hand panel of the page.  It has a wealth of knowledge of you on where you have been and what you like and that is what advertisers love to know.  AOL advertising was usually traditional graphical advertising box that was usually at the top or bottom of the page and took away precious bandwidth when surfing around.  The advertising model was similar to a television station ads.  If you clicked on a Home Improvement page, you saw ads for home improvement just like you would on HGTV. AOL treated you like a TV viewer when it had so much more data on you that could target better ads.

In conclusion, its hard to believe that AOL is still around.  They have a niche of modem users and they are a player in online media content with a new service called AOL On Network.  But when you are owned by Time Warner, you will be a media company.   Facebook is a social network company, and there lies the main difference between two companies.

Wednesday, June 27, 2012

Introduction

I don't own a journal because everyday of my life is not that exciting to report on.  But...there are several moments and insights in my past that I reflect on and want to record them down...somewhere.  This blog will be those entries to my past that I wish to share with my family and to anyone else that is curious about my experiences.

Enjoy!