August08

PhoneApplicationService.Current is null

I just ran into this on one of my Windows Phone projects and thought I would share a little insight into why it happened, and how I fixed it.

This is a project that I have had existing for quite a while, but I copied it all to a new folder and renamed the assemblies.  That is when things went bad. 

Clean up project files first

I remembered that you need to change the namespaces in all the pages (even the XAML), and that you have to remember to go to the project properties and set a new Startup Object.

Clean before you build

Make sure everything is building at this point, but even if it is take a little extra time and right click the project and select the Clean option.  It will remove ALL the files in the obj and bin folders.  This was the actual problem in my case.  There was an OBJ file that had not been correctly rebuilt.  After running clean, the build then went smooth and the PhoneApplicationService object was happy.

Comments are closed