次のように XAML ファイルを動的に読み取るアプリケーションがあります。
StreamReader sr = new StreamReader(pathAndFileName);
this.Content = XamlReader.Load(sr.BaseStream);
読み込まれる XAML ファイルの 1 つ (すべてコード ビハインドが削除されている) では、次のように動作します。
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DynamicXaml123">
<StackPanel Margin="10" HorizontalAlignment="Left">
<TextBox Height="23" Width="100" Text="{Binding FirstName}" />
<TextBox Height="23" Width="100" Text="{Binding LastName}" />
<TextBox Height="23" Width="100" Text="{Binding Age}" />
<local:FieldEmailView></local:FieldEmailView>
</StackPanel>
</UserControl>
しかし、これにより、「タグ 'FieldEmailView' は XML 名前空間 'clr-namespace:DynamicXaml123;assembly=DynamicXaml123' に存在しません」というエラーが発生します。
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DynamicXaml123;assembly=DynamicXaml123">
<StackPanel Margin="10" HorizontalAlignment="Left">
<TextBox Height="23" Width="100" Text="{Binding FirstName}" />
<TextBox Height="23" Width="100" Text="{Binding LastName}" />
<TextBox Height="23" Width="100" Text="{Binding Age}" />
<local:FieldEmailView></local:FieldEmailView>
</StackPanel>
</UserControl>
アセンブリ参照を省略すると、エラーが発生します
Message=""XmlNamespace", "Assembly" oder "ClrNamespace"
XAML を読み取るとき。
ここにアセンブリ参照を含めることができないのはなぜですか?これを機能させるには、何を変更/確認する必要がありますか?