question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing System.Text.Encoding.CodePages reference

See original GitHub issue

Bug Report

Description

Missing reference to System.Text.Encoding.CodePages in latest (0.10.0) version

Steps to Reproduce

  1. Reference AngleSharp NuGet package in your project
  2. Use AngleSharp
class Program
    {
        static void Main(string[] args)
        {
            var parser = new HtmlParser();
            var result = parser.ParseDocument("<html></html>");
        }
    }
  1. Result: Exception
Unhandled Exception: System.TypeInitializationException: The type initializer for 'AngleSharp.Configuration' threw an exception. ---> System.IO.FileNotFoundException: Could not lo
ad file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

Expected behavior: AngleSharp does not throw initialization exception

Actual behavior: Exception thrown.

Environment details: .netcore console app

Possible Solution

Manually adding reference to mentioned package fixes the issue

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:29 (13 by maintainers)

github_iconTop GitHub Comments

4reactions
jgrandydevcommented, Feb 16, 2019

@FlorianRappl I was trying to piggy-back on this issue to avoid opening a new.

W10, VS17, .NET Framework 4.7.2 project

AngleSharp 0.11.0.0 installed via NuGet Package Manager

Yes it installs dependency System.Text.Encoding.CodePages v4.5.0 but this does not resolve issue :

class Program
    {
        static void Main(string[] args)
        {
            var parser = new HtmlParser();
            var result = parser.ParseDocument("<html></html>");
        }
    }

Could not load file or assembly ‘System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.

If I manually update to System.Text.Encoding.CodePages v4.5.1 it does not help.

3reactions
reevevcommented, Aug 26, 2020

I think we’ve confirmed this is definitely not an AngleSharp issue. For anyone with the sae issue, what we’ve found is the binding redirect for System.Text.Encoding.CodePages is being ignored.

In environments that work fusion logs clearly show the binding redirect being picked up:

LOG: Redirect found in application configuration file: 4.1.1.0 redirected to 4.1.3.0. LOG: Post-policy reference: System.Text.Encoding.CodePages, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

In the one environment where the error occurs, these lines are missing from the fusion logs.

We don’t have a solution yet as other binding redirects are working from the applications configuration as expected.

I’ll put this question elsewhere now to try and resolve.

Read more comments on GitHub >

github_iconTop Results From Across the Web

EPPlus: System.Text.Encoding.CodePages.dll not found in ...
The workaround I thought and tested successfully was just to copy System.Text.Encoding.CodePages.dll in the bin folder of my solution. But very ...
Read more >
Could not load file or assembly 'System.Text.Encoding. ...
We tried to add a reference to the whichever System.Text.Encoding.CodePages is installed with Devart Postgresql, to no avail.
Read more >
System.Text.Encoding.CodePages 7.0.0
Provides support for code-page based encodings, including Windows-1252, Shift-JIS, and GB2312. Commonly Used Types: System.Text.CodePagesEncodingProvider.
Read more >
CodePagesEncodingProvider Class (System.Text)
Provides access to an encoding provider for code pages that otherwise are available only in the desktop .NET Framework.
Read more >
Could not load file or assembly 'System.Text.Encoding. ...
I found I was missing some references in the web.config. Adding these in seems to have resolved the issue. <dependentAssembly ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found