Recently I created a post on how I hated XAML parse exceptions because they are non-informative and almost never provide any context to help solve the issue at hand.
Today I found a new error message which takes the cake.
Parser internal error: Object writer ‘xClassNotDerivedFromElement’.
I mean, WTF does this even mean? Of course the stack trace was of absolutely NO help either. I was lucky however, I had only made one small xaml change. I added a new Resource Dictionary which had only one template. I knew I had registered the template so I knew that was not the issue, but what was?
Turns out the root cause of this WTF error message was a leftover x:Class attribute on my ResourceDictionary declaration.
x:Class=”CompanyName.Resources.DataTemplates.GroupDetailsTemplates”
The reason this was in my XAML is due to my lazyness. I Created a new xaml file but used the view template rather than a Resource Dictionary one, yes I deleted the codebehind and all the other namespace declarations. But I guess I did not think to delete the class name attribute.
Once I deleted this attribute the xaml parser was happy as a fat kid in a candy shop.
Hope this helps.
Till next time,