Silverlight AG_E_PARSER_BAD_TYPE Errors
Wednesday, April 8, 2009 at 07:26PM 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!
David Yack |
2 Comments |
Reader Comments (2)
Nice post, it saved me a lot of time and efforts.
Did you let MS guys know about this issue ?
Thanks a lot! Works for me!