Oh XAML, how I hate your error messages

I like XAML, I like some of the cool things I can do with it (although I do wish it was more like CSS in some ways). However, for something that has been around since 2006 why do your error message suck so bad and provide so little information.

Recently while making a very benign change to one of my resource files I received the following error when I launched my Windows Phone 8 application in the emulator.AccessViolationError

Of course I was stumped by this, in fact in my 4+ years of working with XAML I can honestly say that I never remember seeing this error. To try to resolve the issue I did what any good developer would do, stop the app and try again… It still happened.

Next, I thought maybe the emulator vm was screwed up so I killed the emulator and restarted… It still happened.

Ok, I knew it had to be something I did so I started diff’ing all the files I have changed to see if I could find what is causing this, fortunately for me I had only changed a few files and most were resource files. Immediately I noticed the issue, I had fat fingered something in my resource file, see below.
BadXaml

Notice how at the end of my line I had added an inadvertent slash at the end, yea this was my issue. So it turns out that invalid markup will give you the error mentioned above… WTF, really? Why is this not some sort of parse error?

I would totally have expected to get a parse error with the EXACT line number the error occurred, not some obscure error about memory. #Fail

Oh well, I should have known better I guess.

Till next time,

This entry was posted in Windows Phone and tagged . Bookmark the permalink. Follow any comments here with the RSS feed for this post.

Leave a Reply