How To Access Unhandled Exceptions In Windows Phone 8.1 WinRT App

I was recently looking at the latest Windows Phone 8 questions over at Stack Overflow and I saw this one. Avinash was asking how to save an explicit version of the crash dump on his Windows Phone 8.1 WinRT app.

I haven’t converted my apps to WinRT or played with WinRT apps yet, but I decided to create a test project to see if I could answer his question. A simple Google search didn’t return any good results so after I figured it out, I decided to write this post.

This only applies to Windows Phone 8.1 projects that use Windows Runtime. You do not have to do this if you are creating a Silverlight 8.1 app as it is already done for you.

What happened to Application_UnhandledException?

For some reason, when you create a new Windows Phone 8.1 project that uses the Windows Runtime (WinRT), inside App.xaml.cs you won’t find the Application_UnhandledException event handler that exists in the Silverlight 8.0 and 8.1 project templates.

In WinRT, you have to write the event handler method and subscribe to it manually.


Open App.xaml.cs and add the following line in the constructor:

this.UnhandledException += Application_UnhandledException;


Now add the event handler method:

void Application_UnhandledException(object sender, UnhandledExceptionEventArgs e)
	// You can process the unhandled exception here


Now inside the event handler you have access to the unhandled exception and you can save a log if you want. If you are looking for a good and quick Crash Report solution for Windows Phone apps which lets the users email the crash report, you should check this post by Simon (look at the Silverlight section).

Hopefully this clears the confusion on how to access the Unhandled Exceptions in WinRT templates.

How To Fix TweetSharp After Recent Twitter Changes

Three days ago, I was contacted by a Tile Me! user telling me that the Twitter integration in the app did not work for him. I checked on my phone, everything was fine. I could also see other people were using it just fine too. So, I gave the default instructions of “Have you tried reinstalling the app?"’ which did not help 😦 .

Yesterday, I gave the user an account name and password that I control for app testing, just to see if the problem is with the app or the account he is trying to log in with. Lo and behold it works, while his accounts (yes he created several) don’t. That doesn’t make sense, does it?

After this, I decided to create a new Twitter account myself and test with that. Of course it does not work. I got in touch with Robert Shurbet and Sébastien Lachance who are both using TweetSharp in their apps. Robert said that he encountered this error before and he coded the authentication with a RestClient himself, while Sébastien was not aware of this issue which caused his app to crash altogether. The guy user that first reported this problem had created his Twitter account in February 2014. So, this problem might have been there for a while.

If you are using TweetSharp 2.3.0 (which is the stable version) or a modified 2.3.1, try creating a new Twitter account and see if you can log-in with it. If you can’t, read on.

The Problem

I noticed that the problem was with the access tokens. For some reason, TweetSharp  was returning a ‘null’ access token when I logged in with a newly created Twitter account. I examined the TwitterResponse object which at first glance seemed fine. The status said ‘OK’. But, clearly it was not OK. After digging some more, I found out that an inner exception had occurred during the processing of the access token and was logged in the TwitterResponse object.

The exception that was logged said something along the lines of “Value assigned is greater than Int32’. I thought that must be it. They probably changed the type of something from’ ‘int’ to ‘long’. To investigate further, I had to download the TweetSharp 2.3.0 source code.

Now that I could access the TweetSharp classes, I found out that the culprit was the ‘UserId’ in the OAuthAccessToken class.

The Solution

The solution was quite simple. Change the ‘UserId’ type from ‘int’ to ‘long’ and find what else I broke by doing that. After building the project, I got a few errors at a few lines in the TwitterService.OAuth.cs class where the ‘UserId’ property was used.

In order to fix the errors all I had to do was replace all the occurrences of:

UserId = Convert.ToInt32(query["user_id"] ?? "0"),



UserId = Convert.ToInt64(query["user_id"] ?? "0"),


I built the project, replaced the .DLL that I was using from nuget with the newly compiled one, and voila everything was fixed. I also sent the .DLL to Sébastien which reported that the problem was fixed in his app as well.

If you want to edit the things yourself, download the source code and do the changes above. If you are lazy to do that, don’t worry, you can download the Windows Phone 8 .DLL I compiled from here. If you installed TweetSharp from nuget, just navigate to your project directory –> Packages –> TweetSharp.2.3.0 –> lib –> sl4-wp and replace TweetSharp.WindowsPhone.dll 

If you are using TweetSharp for WP7 or another platform, you’ll have to do the changes yourself (it’s the same ones).

Note: The developer has stopped supporting TweetSharp, so if you are creating a new app, use another alternative instead. I cannot guarantee that TweetSharp won’t break again anytime soon.  I heard Linq2Twitter is currently popular among developers.

Promote Your Windows Phone Apps With Device Shot

Few months ago, when I added a Twitter Background creator to Tile Me! I got this idea to create an app that would quickly generate in-device shots from your images. At that time, I thought it could be used by ordinary Windows Phone users to share their home screens. But, after talking to Robert Shurbet (the developer of #Hashtastic who I collaborated with to add the Avatar Gallery feature) I realized this kind of app would be great for developers to promote their apps on social networks too.

About two weeks ago I started implementing the idea and had a closed beta with few other developers who really contributed with the design choices. I’d like to thank Sébastien Lachance, Robert Shurbet, Hermit Dave and Mark Tepper. Special shout out to my brother Alpay for all the phone renders he managed to find and edit on the interwebs, the app wouldn’t exist without him.

Device Shot went live two days ago and was well received by many Windows Phone users. WPCentral published an article too! Along with App Promo by Sébastien Lachance, I believe they are currently the two best apps for developers to promote their own apps. On the left you can see an image generated with Device Shot for Rob Irving’s Car Dash.

I already submitted an update which is under certification to add support for Landscape images/screenshots too.

You can get Device Shot by scanning the QR code below. The trial version let’s you save up to 3 images. To remove that limitation you can purchase it for $0.99.



OneSky–A Great Translation Service For Localizing Your Apps

I have noticed a few times now under the #wpdev hashtag, some developers are asking for the best method for translating apps. I’ve seen some devs are uploading an Excel file to SkyDrive OneDrive, and give a link to the people who are willing to translate. This is definitely not a bad approach, but I think OneSky is much better. A fellow developer from Portugal told me about this free service, so here’s a shout out to Diogo Cardoso.

Note: This service is not Windows Phone specific. It can be used for Android, iOS etc. Supports a lot of formats (.resx, .xml, .xls etc.)

Why You Should Localize Your App

If your native language is English and you don’t speak any other language, how would you feel if there was some awesome app that is very popular in Brazil but it only supports Portuguese? Of course you won’t be happy. Our main goal as app developers is to make people happy and provide quality apps (*cough* and earn some money of course).

You should make the effort and translate your app into at least 2 of the following languages: Portuguese (Brazil is a huge Windows Phone market), Spanish (you cover Spain and most of South America), French (France, Canada, also big markets) and German. If you can also support Chinese, Russian and Hindi, that would be even better.

After I added more languages to Tile Me!, the coverage from international Windows Phone sites increased drastically.

Why OneSky?

  • It is completely free if you want to crowdsource your translations!
  • Online editor that works on most browsers. I even had a translator that translated Tile Me! into German on his Windows Phone.
  • You can give a link to your OneSky site where people can Request to Contribute to a language of their choice. You then approve or reject that request.
  • Upload non-translated .resx files and download the finished translations in .resx format.
  • Specify maximum length of words. For example, if the words are too long for the App Bar icons, they will not be fully shown. You can specify the character length of a translation so the translator can try to find a shorter synonym which won’t mess up the UI.
  • Notifies the translator if spaces are missing.
  • When you prepare a new update where you remove some strings and add others in your .resx file, you can upload the new .resx and OneSky detects the same strings, removes the ones you have removed, adds new ones that you have added, but does not touch the ones (along with their translations) that you haven’t changed.
  • If you update a string in a new update, the translators can filter by ‘Outdated words’ and see what you have changed so they can update the translation for that line.
  • Your translators receive an email every time you add new words for translation.
  • Voting, commenting, reviewing, moderating and other features for organizing your translators and workflow.

Quick Start Guide

Go to and create a new Free account. Once you’ve done that, on the top go to Projects –> Create Project. On the next page, choose Mobile Apps / Games.

Select Crowdsource under translation method, choose your platform (Windows Metro App is fine for Windows Phone apps), select your base language and enter your app name.

Next, drag and drop your AppResources.resx file. Click Continue and select the languages you want to translate to.

And you’re done. Now you can invite collaborators to contribute to each language, or on the top go to Collaboration –> Collaboration Site and share that link on Twitter, Facebook etc. From that link, people can request to translate your app. You can also add that link somewhere inside your app.

Then, from the project page you can track the number of translated words, remaining words etc. Once a translation is completed you can download the file as shown on the screenshot below:

And that concludes my brief quick start guide. I strongly advise to check the knowledge base if you need some more info about a specific feature. Feel free to leave a comment below if you get stuck somewhere.


Join The Me Tile Nation Now!

I spent the last two days working on a video commercial for Tile Me! I’d like to thank my brother for helping out with the editing and also everyone else that took part in the ad. Enjoy!