Sunday, February 22, 2015

Project is not a WPF project.

For the last year, I've mostly just been maintaining my PAX app by adding the new schedule data and maps for each new PAX event. The last few times I opened it up to do that, I noticed that the design window always showed "Invalid Markup" for my xaml files, and sometimes when I built the project I got a strange avalanche of build errors, including
Error 50 Application is not supported in a Windows Presentation Foundation (WPF) project.
Error 47 Cannot add content to an object of type "ApplicationBar". 
Error 5 Cannot add content to an object of type "PhoneApplicationPage".

I had no idea how to fix it, or why it was occurring - obviously, my project was not and never had been a WPF project. I made some notes for myself like 'closed Visual Studio, deleted bin and obj files, re-opened, and it was fixed' - then when it happened again, following the same process wouldn't fix it! 

Finally this time, I managed to work it out. These errors occur if I have a *.xaml file open in the editing pane when I run a build. Wow. 100% reproducible, too. At least it's easy to fix...