Windows Phone taskhost.exe error

(Thanks to Diego H for his solution to this one. He posted the solution on the Windows Phone Jump Start forum and I’ve found it very useful.)

image

When I’m writing Windows Phone programs I’ve noticed that I sometimes get the above error when I try to deploy a Windows Phone 7 project to the emulator. This is usually after I have moved or copied the Visual Studio solution to another directory. 

If I don’t get this error I might notice an even stranger manifestation, where changes I’ve made to the program don’t seem to be reflected in the running code. It turns out that this is due to a build setting getting corrupted. To fix it you must go to the Build menu and select Configuration Manager. Then re-select Windows Phone as the Active solution platform, so that the dialog looks as shown below:

image

Then your programs will deploy and run OK. I’ve no idea why this happens, but sometimes this gets set to “Any Platform” with no build or deploy options set, which stops programs from being built or deployed.