How to fix Parser internal error: Object writer 'xClassNotDerivedFromElement

I faced this error recently and have to say it was very annoying especially due to the fact that the error details do not offer many clues as to the source of the problem.

Fortunately I found the below blog entry which guided me in the right direction:

I was trying out windows 8 metro apps, and as it turns out, the “Default Namespace” in the project properties should be the same as the namespace of App.xaml for it to work.