Passing Async Task functions as a parameter

Some Motivations

If you have programmed Windows Phone or Windows Store apps, you may know about Dispatcher in Windows Phone or CoreDispatcher in Windows Store. In this article I will focus more on Windows Phone implementation, but basically this should be very similar in Windows Store.

In general, those dispatchers are ways to marshal UI interactions from a background context (any context that is not the UI context) to the UI. Trying to directly access (both read and write) any UI control or any view model property that has been bound to a UI control from a background context will trigger an UnauthorizedAccessException. Instead you will have to call Dispatcher.BeginInvoke(Action action) method (or Deployment.Current.Dispatcher.BeginInvoke(Action action) if you are not in a page) and put all the UI accessing codes in the action parameter.

It work perfectly fine until I tried to introduce some async logic inside.

You could do it simply this way:

Read More

Windows.Launch contract failed with error: The app didn’t start

I recently met a problem with my Windows 8 app, when only the splash screen’s image showed up and the app crashed. Even App object is not initialized yet so there’s not much I can do with the debugging tools in Visual Studio.

I tried to check Package.appxmanifest, but nothing seemed strange there. Project properties also looked perfectly ok. So I tried to dig in the Event Logs. A quick look in Microsoft-Windows-TWinUI/Operational log (inside Applications and Services Logs/Microsoft/Windows/Apps) revealed several error logs: “Activation of the app <app name> for the Windows.Launch contract failed with error: The app didn’t start.” but there was no other useful information. Searching on the internet did not help either.

I decided to take a look at the changes from last revision, and l suddenly realized the file app.config was added to the project. I suppose Nuget or VS somehow misunderstood the project type and put the file there for assembly binding, and this file prevented app activation from complete successfully. Removing the file and everything go back to normal.

I have already met the same problem before (and I believe someone has also written about this), but I completely forgot about it, and it cost me so much time. So I decide to write the solution down here, to make sure I can solve the problem faster in the future.

How searching has changed in Windows 8.1

There have been many welcome changes from Windows 8.0 in Windows 8.1, both in the users and developers’ perspective. However, I believe not all of those changes are really improving the user experience (I still think some are only make to dodge the media critics). One of those is the introduction of the hero Search screen, where your search result is now the accumulation from installed apps, Windows settings, local files, Windows Store and Bing results (including some big images and information about the recognized entity, Web images, Web videos and websites). I remember they said about one page where you could get the search results from everywhere, but I still do not see search results from data inside my own apps.

Continue reading my comparison and opinion

Windows Store Protocol to check for app updates

If you have used a Nokia Lumia phone, you may already see how Nokia forces the users to update their apps. They put the blank page with a background image and an Update button right after the splash screen (if there is one); tapping the button will get you to the app’s detail page in Windows Phone Store and you can update the app directly there. On the developer side, to do the same thing, you just have to use the API exposed through MarketplaceDetailTask to jump to that detail page.

The situation seems to be more complicated on Windows 8 with the Windows Store. Unlike the Windows Phone Store, going to the app’s detail page in Windows Store will not show you any update buttons. Instead, you will have to go to Settings charm of the Store, choose App updates and tap on Check for updates. How to do all these steps programmatically from your app (to help your users to quickly update the app)?

I had thought about showing a screen with screenshots telling people to do all the above steps by themselves, but it seemed to be too troublesome for the users. Then I saw an ads on Bing Sport app showing that there was an update in the Store, tapping on the ads jumped us directly to the Check for updates page, which is so nice and convenient! Therefore, I realized the Windows Store must already handle some special kinds of protocols or URL formats for that, and after some times trying, I figured out the magic words:

ms-windows-store:updates

Basically, you will just have to call that URL by a Launcher and the Store will start checking for app’s updates immediately!

Update: I have also checked that URL in Windows 8.1 and can confirm that it still works in the new Store.

DEP0700: Registration of the app failed. Another user has already installed a packaged version of this app.

If you are developing Windows Store apps and you have multiple accounts on your laptops or PCs, you may be familiar with this problem. This happens when you try to install or deploy an app on your testing devices when the app is already deployed (by Visual Studio or PowerShell) on another user account. You will have to log in to that account to remove this app first. Sound troublesome, at least it works.

But what if you have just removed that problematic user account without uninstalling the app beforehand? I got into that weird situation when I try to test Project Timeline on a new testing account and delete the old one: I could neither deploy the app (even install from the Store) nor uninstall from the deleted user account.

Wandering around the internet, I saw several suggestions to solve this. One of them was to simply change the family name, which was not very convenient for me since I wanted to test the IAPs as well. Trying different other suggestions, I finally found a good solution: just remove the PackageRepository.edb file, and everything worked normally again. You could read the details in this blog post:

http://blog.falafel.com/Blogs/JonathanTower/j-tower/2013/04/04/fixing-windows-8-deployment-error-error-dep0700-registration-of-the-app-failed-

I have also come up with another solution which does not actually solve my problem but provide a way to remove all the deployed apps quickly.

http://stackoverflow.com/questions/13865930/how-to-uninstall-an-app-that-another-user-installed

Update: I have a problem now. After a while, all the Windows Store apps (except IE) on my tablet stop working: they stopped showing up when I tapped their tiles and the event viewer showed problem with their license. I am still not sure if removing the PackageRepository.edb caused the problem or my messing around earlier did. I have tried to remove the developer license, reinstall it again, remove old user accounts, add new ones, and some others, but only Store app and newly installed apps were working then. I finally have to refresh the devices. Luckily, the problem was then solved and all the Windows Store apps were keep intact.