I am trying to Parse a XML file using the XamlReader which has the following contents
<Canvas xmlns:seic="clr-namespace:NameSpace1;assembly=Assembly1"
xmlns:seidm="clr-namespace:NameSpace2;assembly=Assembly2"
xmlns:seogptpi="clr-namespace:NameSpace3;assembly=Assembly3"
xmlns:seogdc="clr-NameSpace4;assembly=Assembly4"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="_99abfc59e3ad417d98db31591a6f9dd7"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Canvas.Left="0" Canvas.Top="0" Tag="TemplatePart" Width="800" Height="600"
seogdc:FrameworkElementExtensions.Id="Canvas"
seogdc:FrameworkElementExtensions.ShowRotateCue="False"
seogdc:FrameworkElementExtensions.ShowPositionCue="False"
seogdc:FrameworkElementExtensions.IsSizeSerializable="False"
seogdc:FrameworkElementExtensions.IsTargetDimensions="False">
<Canvas x:Name="Canvas1"
Canvas.Left="0"
Canvas.Top="0"
Tag="TemplatePart"
Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType={x:Type Canvas}}, Path=Width}"
Height="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType={x:Type Canvas}}, Path=Height}"
Background="{x:Static Brushes.Black}"
seogdc:FrameworkElementExtensions.Id="Canvas"
seogdc:FrameworkElementExtensions.ShowRotateCue="False"
seogdc:FrameworkElementExtensions.ShowPositionCue="False"
seogdc:FrameworkElementExtensions.IsTargetDimensions="False"
seogptpi:TemplateManager.IsMainPart="True"
seogptpi:TemplateManager.TemplateName="Canvas">
<seic:DomainParameter.DomainModel>
<seidm:StatelessDomainModel>
<seidm:StatelessDomainModel.DomainFeatures>
<seidm:ColorFeature LabelFillTransparency="0">
<seidm:ColorFeature.FontBlinkSetting>
<seidm:ColorTransparancy Transparancy="0" />
</seidm:ColorFeature.FontBlinkSetting>
<seidm:ColorFeature.LineBlinkSetting>
<seidm:ColorTransparancy Transparancy="0" />
</seidm:ColorFeature.LineBlinkSetting>
<seidm:ColorFeature.FillBlinkSetting>
<seidm:ColorTransparancy Transparancy="0" />
</seidm:ColorFeature.FillBlinkSetting>
</seidm:ColorFeature>
</seidm:StatelessDomainModel.DomainFeatures>
</seidm:StatelessDomainModel>
</seic:DomainParameter.DomainModel>
</Canvas>
</Canvas>
But it simply throws an XamlParseException('Cannot set unknown member 'Namespace2.ColorFeature.LabelFillTransparency'.' Line number '13' and line position '31'.) all the time. I have added references to the 4 assemblies mentioned above. For privacy purposes i have chosen not to provide the exact assembly names. Can someone tell me what might be happening?
Thanks in advance.
You need to provide a custom
ParserContext
to theXamlReader.Parse
method. You should assign theParserContext.XamlTypeMapper
property to enableXamlParser
to locate the types referenced in your XAML. Something along these lines: