Missing System.Text.Encoding.CodePages reference
See original GitHub issueBug Report
Description
Missing reference to System.Text.Encoding.CodePages in latest (0.10.0) version
Steps to Reproduce
- Reference AngleSharp NuGet package in your project
- Use AngleSharp
class Program
{
static void Main(string[] args)
{
var parser = new HtmlParser();
var result = parser.ParseDocument("<html></html>");
}
}
- 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:
- Created 5 years ago
- Comments:29 (13 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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 ManagerYes it installs dependency
System.Text.Encoding.CodePages v4.5.0
but this does not resolve issue :If I manually update to
System.Text.Encoding.CodePages v4.5.1
it does not help.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.