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.

Could not load file or assembly 'System.Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

See original GitHub issue

Repro steps

Provide the steps required to reproduce the problem:

  1. Create function app project
  2. Install System.Text.Encoding.CodePages nuget package
  3. Adding Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); to function
  4. Run function app

Expected behavior

Function app is executed without error

Actual behavior

The following error occurs and the function cannot be executed.

[2021-01-15T07:00:17.378Z] A host error has occurred during startup operation 'e356b46a-f0fb-44a1-8494-df0ad91f3d36'.
[2021-01-15T07:00:17.380Z] FunctionApp34: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 指定されたファイルが見つかりません。.
Value cannot be null. (Parameter 'provider')

Known workarounds

  • Adding _FunctionsSkipCleanOutput setting
  • Downgrade System.Text.Encoding.CodePages to v4.7.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
lars-erikcommented, Jan 18, 2021

I have the same problem. The publish targets remove a lot of stuff.
The System.Text.Encoding.CodePages.dll is copied into bin/runtime/netstandard2.0.
It seems like files under bin/runtime/** are not probed at all.
I’ve tried this with both V2 and V3 runtime, including pretty much all framework targets since netstandard2.0.

I managed to get the file copied to the bin folder locally with an extra target in my .csproj, but I couldn’t figure which target / filegroup / property to use in order to include the file in the .zip that is published.
So for now I grudgingly copy the file into the function’s bin folder using the kudu console.

Let me know if I can help by providing more details. Here’s my targets:

  <Target Name="ForceCopyCodePages" AfterTargets="_FunctionsBuildCleanOutput">
    <Message Importance="High" Text="Copying messed up deps to $(OutputPath)" />
    <Copy SourceFiles="$(OutputPath)bin\runtimes\win\lib\netcoreapp2.0\System.Text.Encoding.CodePages.dll"
          DestinationFolder="$(OutputPath)bin"/>
  </Target>
  <Target Name="ForcePublishCodePages" AfterTargets="_FunctionsPostPublish">
    <Message Importance="High" Text="Copying messed up deps for publish to $(PublishDir)bin" />
    <Copy SourceFiles="$(OutputPath)bin\runtimes\win\lib\netcoreapp2.0\System.Text.Encoding.CodePages.dll"
          DestinationFolder="$(PublishDir)bin"/>
  </Target>
1reaction
aaronhudoncommented, May 15, 2021

Why is this about to be closed? I am seeing the issue myself running latest Functions SDK 3.0.12

Read more comments on GitHub >

github_iconTop Results From Across the Web

EPPlus: System.Text.Encoding.CodePages.dll not found in ...
The ExcelPackage instanciation will raise the following error: "Could not load file or assembly 'System.Text.Encoding.CodePages, Version=5.0.0.0 ...
Read more >
Azure Functions - Could not load file or assembly System. ...
Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Read more >
Could not load file or assembly 'System.Text.Encoding. ...
Re: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b0.
Read more >
Could not load file or assembly 'System.Text.Encoding. ...
Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.... I tracked down the File version ...
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 >

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