Welcome to Pete Brown's 10rem.net

First time here? If you are a developer or are interested in Microsoft tools and technology, please consider subscribing to the latest posts.

You may also be interested in my blog archives, the articles section, or some of my lab projects such as the C64 emulator written in Silverlight.

(hide this)

Debugging XAML Errors with Silverlight

Pete Brown - 10 June 2007

When programming in silverlight 1.1 in Orcas, you'll often find an exception being tossed by the InitializeFromXaml method of controls. In our case, since all the logical pages except for the root are implement as controls, this happens quite a bit.

Unfortuantely, the debugging information isn't very helpful. If you bungled something in the XAML, you'll get an AG_E_PARSER_xxxx error. Equally as unhelpful is the XAML editor in Orcas. (That's because Orcas is just using the XML editor with a XAML XSD).

If you don't already have Blend, download the Blend 2 evaluation and use that to help debug your XAML. While its XAML editor is far worse (and much slower) than the editor in Orcas (note to MSFT: please add collapsing sections to the Blend XAML editor!), it will validate/compile your XAML for you and let you know exactly where you have errors.

In my latest case, I was getting an AG_E_PARSER_PROPERTY_NOT_FOUND error because I had typed "Test" instead of "Text" for a property. There was no correct line information (the exception has some line number information that just didn't make sense), and the xaml file was fairly large. Blend picked that right up and brought me right to the line.

I find that for various reasons, I bounce back and forth a lot more between Blend and Orcas than I did when doing WPF. In Silverlight, you'll find you have to just write more code to do navigation and whatnot than you did in WPF. That's fine, and to be expected (especially in a 1.1 alpha), but the Designer/Developer workflow isn't yet quite as solid as I hope it will be.

There are other editors out there that will also validate your XAML for you, but you'll want to use Blend for the design experience anyway, so go give it a try.

 
posted by Pete Brown on Sunday, June 10, 2007
filed under:  

Comment on this Post

Remember me