views:

602

answers:

1

I'm trying to load a xaml file at runtime. My code looks like this:

StringReader stringReader = new StringReader(xamlString);           
            XmlReader xmlReader = XmlReader.Create(stringReader);
            content = XamlReader.Load(xmlReader);

It's basically copy paste of of msdn. the XamlReader.Load line throws a XamlParseException with an inner exception of "Stack Empty at line....".
The line it points to is the closing tag of the user control found in the xaml string, the last line of the string.

The basic Xaml structure is as follows

<UserControl>
    <UserControl.Resources>
    </UserControl.Resources>
    <Grid>
    </Grid>
</UserControl>

Googling didn't turn anything up. Any help in find a solution is much appreciated.

A: 

I just started chopping blocks out of my xaml until the error went away. I was able to narrow it down to this line found in my user control declaration

<UserControl
...
WPFManagement:ObjectReference.Declaration="{WPFManagement:ObjectReference thisPointer}"
...>

Not exactly sure why that throws a Stack Empty exception, but it does.

Here is the entire Header with the culprit in bold

<UserControl 
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:WPFManagement="clr-namespace:A;assembly=A"
         xmlns:WPFControls="clr-namespace:B;assembly=B"
         xmlns:ModuleUI="clr-namespace:C;assembly=C"
         xmlns:GeneralUI="clr-namespace:D;assembly=D"
         **WPFManagement:ObjectReference.Declaration="{WPFManagement:ObjectReference thisPointer}"**
         mc:Ignorable="d"
         WPFControls:UIExtension.Caption="Filler"
         WPFControls:UIExtension.Icon="Icon"
         d:DesignWidth="910"
         d:DesignHeight="730">
JRobbers