Not a subscriber?

Join thousands of others who are building self-directed lives through creativity, grit, and digital strategy—breaking free from the 9–5.
Receive one free message a week

XamlParserException – AG_E_PARSER_BAD_TYPE

Ohhhhh the dreaded XamlParserException. The exception message is not to helpful at all.

In my instance I was working with Silverlight. Namely working with the Prism  V2 Drop #5 from the Composite WPF team. Get the latest and read up the project here. I was loading the TreeView control into my view (Xaml) and when the app fired up the project would bomb with this exception and the message was VERY informative *sarcasm*.

AG_E_PARSER_BAD_TYPE

Hmm… Ok. Sure. Sounds good.

I have my projects laid out like so.

image

 

The Prism Shell (Top) loads different modules at runtime. Module A has a view (View 1) which has a tree view. Therefore, Module A (which is a Silverlight App itself) references the Microsoft.Windows.Controls library which contains the new controls for Silverlight (download them here). When this was getting compiled and referenced at runtime, the Microsoft.Windows.Controls dll was not in the Shell project, therefore it would blow up when it tried to parse the Xaml. Giving me the lovelly and dreaded XamlParserException.

The Fix

Simple. Add a reference to the Microsoft.Windows.Controls dll in the main Prism App. Then…. BLAMMO… the control toolkit works as expected.