Search
More About This Website

All information is provided "AS IS" with no warranties, and confers no rights

Login
« Silverlight 3 Out of Browser and Data Services | Main | Silverlight 3 Means Business »
Wednesday
Apr082009

Silverlight AG_E_PARSER_BAD_TYPE Errors

The AG_E_PARSER_BAD_TYPE error isn’t a new error but one that if you get can sometimes give you a headache!  In reading some of the forum posts like this one you read things like renaming, inherited user controls etc can cause them to happen.  Today and a few times in the past I’ve hit this with particular obvious reasons it happened. 

The most common scenario I’ve seen is where you have a user control in a class library “Lib A” and it’s used by an application “App A”.  When running App A it produces a AG_E_PARSER_BAD_Type when the user control in App A tries to call InitializeComponent().  What’s interesting is in trying to create a repro for the Silveright team I’ve tried several times creating an App B, and App C that use Lib A and no luck those work fine. 

What’s even more interesting is what I’ve found fixes it and gets the InitializeComponent() method to run fine.  Simply by creating an instance in the code behind of the Lib B user control prior to calling InitializeComponent does the job.  I could probably dig a little deeper to find why that helps, but sometimes a little mystery is ok!

So as you can see in the following example adding the dummy instance of MapBuilderControl did the job.

public PropertyMapping()

        {

  MapBuilderControl x = new MapBuilderControl();

            InitializeComponent();

        }

Clearly, that’s far from the ideal resolution, but if you find yourself getting this error – give it a try!

Reader Comments (2)

Nice post, it saved me a lot of time and efforts.
Did you let MS guys know about this issue ?

July 27, 2009 | Unregistered CommenterLevon

Thanks a lot! Works for me!

August 28, 2009 | Unregistered CommenterIgor

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>