Resolving FileNotFoundException for System.Text.Encoding.CodePages in RadWordsProcessing
Environment
| Version | Product | Author |
|---|---|---|
| 2024.2.426 | RadWordsProcessing | Desislava Yordanova |
Description
When you use RadWordsProcessing in a WPF/WinForms project that targets .NET 6.0, a System.IO.FileNotFoundException error occurs. The error states that the file for assembly System.Text.Encoding.CodePages, Version=7.0.0.0 cannot be found. This issue arises when you use the Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider.


Solution
To resolve the FileNotFoundException for System.Text.Encoding.CodePages in a .NET 6.0 project that uses RadWordsProcessing, follow these steps:
-
Right-click your project and edit the
.csprojfile.
-
Add the
PackageReferenceentry forSystem.Text.Encoding.CodePagesand aFunctionsPreservedDependenciesentry for it:
<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>

These entries include the required package references in your project and resolve the FileNotFoundException.
Ensure that your project targets .NET 6.0 and that all NuGet package versions are compatible with your project setup.