none
System.Windows.Markup.XamlParseException:Type reference cannot find public type named RRS feed

  • Question

  • I am attempting to use XamlReader to load styles dynamically. The XAML below works without issue when it is included it in my project, i.e. it gets compiled into the assembly, however when I try load it dynamically at runtime it fails with the exception below.

    I assume that even although I have the namespace defined in the XAML "

    xmlns:sbc="clr-namespace:MyNameSpace;assembly=CO.MyAssembly"

    ", the XAML Parser is still failing to resolve the type. So how to I get around/solve the problem?

     

    Thanks

    Kendrew

    Exception;

    :System.Windows.Markup.XamlParseException:Type reference cannot find public type named 'MyClass'. 
       at System.Windows.Markup.XamlReaderHelper.Read(XamlNode& xamlNode)
       at System.Windows.Markup.XamlParser.ReadXaml(Boolean singleRecordMode)
       at System.Windows.Markup.XamlParser._Parse()
       at System.Windows.Markup.StyleXamlTreeBuilder.ParseFragment()
       at System.Windows.Markup.XamlStyleSerializer.ConvertXamlToObject(XamlReaderHelper tokenReader, ReadWriteStreamManager streamManager, ParserContext context, XamlNode xamlNode, BamlRecordReader reader)
       at System.Windows.Markup.TreeBuilderXamlTranslator.WriteElementStart(XamlElementStartNode xamlElementStartNode)
       at System.Windows.Markup.XamlParser.ProcessXamlNode(XamlNode xamlNode, Boolean& cleanup, Boolean& done)
       at System.Windows.Markup.XamlParser.ReadXaml(Boolean singleRecordMode)
       at System.Windows.Markup.TreeBuilderXamlTranslator._Parse()
       at System.Windows.Markup.XamlTreeBuilder.ParseFragment()
       at System.Windows.Markup.TreeBuilder.Parse()
       at System.Windows.Markup.XamlReader.XmlTreeBuildDefault(ParserContext pc, Stream stream, XamlParseMode parseMode, Boolean etwTracingEnabled)
       at System.Windows.Markup.XamlReader.Load(Stream stream)

    Code

    MemoryStream stream = new MemoryStream(Encoding.Default.GetBytes(skinText));

    object res = XamlReader.Load(stream);

    XAML;

    <ResourceDictionary

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:sbc="clr-namespace:MyNameSpace;assembly=CO.MyAssembly"

    >

    <Style x:Key="FormContentStyle" TargetType="{x:Type ContentControl}">

    <Style.Triggers>

    <DataTrigger Binding="{Binding Path=CurrentForm, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type sbc:MyClass}},

    Mode=OneWay,

    Converter={StaticResource IsNullConverter}}"

    Value="false">

    <Setter Property="Template">

    <Setter.Value>

    <ControlTemplate TargetType="{x:Type ContentControl}">

    <Grid>

    </Grid>

    </ControlTemplate>

    </Setter.Value>

    </Setter>

    </DataTrigger>

    </Style.Triggers>

    </Style>

    </ResourceDictionary>

    Thursday, February 22, 2007 10:44 PM

All replies