Sep 092010

The other day while working on a Silverlight application I received the following error:
“Parser internal error: Object writer ‘xClassNotDerivedFromElement’. [Line: N Position: N]
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)”
When calling the InitializeComponent() internal method on a custom user control.

So I did what I did best and searched Google for the answer, and while I didn’t end up finding my solution there I did find more about what can cause this error to occur.

The fully qualified name in the x:Class element has to inherit from the same underlying class that your base xaml element is. So if your class inherits from the UserControl class then your base element in your xaml needs to be .

So for instance if you change your class to inherit from a different class you must also change the root element to reflect this change. If you don’t you will experience this error at Runtime, which does not give you much to go on.

This error can also be caused by a lack of a namespace in the x:Class property of your base element. You need the fully qualified name of the class that it implements including the full namespace.

Even though these two issues are related, the cause and solutions are different. It is also possible that this error could be caused by something else, but these two situations are the only ones I’ve come across.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.