In a WPF project targeting .NET 6, the following code snippet results in an error:
public MainWindow()
{
InitializeComponent();
Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider provider = new Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider();
RadFlowDocument document = provider.Import("<html><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>");
}
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Text.Encoding.CodePages, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.'
Workaround: edit the .csproj file and include the required package reference:
<ItemGroup>
<PackageReference Include="Telerik.Windows.Documents.Flow" Version="2024.2.426" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<FunctionsPreservedDependencies Include="System.Text.Encoding.CodePages.dll" />
</ItemGroup>