Wednesday, April 21, 2010

Parser internal error: Object writer 'xClassNotDerivedFromElement'

If you are a Silverlight developer there is a chance that you may get the exception “Parser internal error: Object writer 'xClassNotDerivedFromElement'” very rarely which is difficult to track.Even you can’t put break points to track this.As a developer you will google the same.But most probably you will not get any results.

Only thing went wrong here is the namespace.But this is not at all mentioned in any of the exception details.ie The project which you are working on will not have a namespace or somebody in the project might forgot put the namespace in XAML or code files.

So make sure that there is namespace present in the project and the xaml files are correctly mapped to the corresponding code files in the x:Class attribute.

Note : We cannot have Silverlight projects without namespace.

I came to see this exception when one of my colleagues tried to write code which should  compile in both Silverlight 4 and WPF 4.

11 comments:

Keren said...

Thank you so much for this comment!
It was a real big help. :-)
Thanks!

Nick said...

Same over here - thanks very much :)

MagicT said...

Wow, that just saved me a lot of heartache...I'm moving Controls developed in Blend over to a Visual Studio Environment...

Maciej said...

You just saved my day. I have used a refactoring functionality of ReSharper 5.1 named "Adjust namespaces" for a whole Silverlight navigation project. That operation has added an x:Class namespace definition to the MainSkin.xaml.

Damn! ;) I have removed this namespace, and everything worked as expected.

Thank You for your post!

Joymon | ജോയ് മോന്‍ | जोय मोन | ஜோய் மோன் said...

Happy to hear that it saves many hours of Silverlight developers...

Alvaro Dias said...

tnx... very helpful

hiovidiu said...

Thanks man, you just saved me from a headache

Andreas said...

Came across the same error and the issue was a xaml reference in a ResourceDictionary, which was wrong. It pointed to the wrong file. Worth checking these Dictionaries, if you run into this error message.

Joy George said...

Hi Andreas,
Thanks for sharing the information.
Joy

Nepalese In Iowa said...
This comment has been removed by the author.
Nepalese In Iowa said...

Remember this is also Sase Sensitive
somehow, I did .app on the x:Class