azure-functions-host: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Repro steps
Provide the steps required to reproduce the problem:
- Create function app project
- Install
System.Text.Encoding.CodePages
nuget package - Adding
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
to function - 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
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 16 (3 by maintainers)
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:
Why is this about to be closed? I am seeing the issue myself running latest Functions SDK 3.0.12
@SOFSPEEL I have confirmed that it works with the first workaround I wrote. It’s not wrong.
@v-bbalaiagar The workaround is described in the first comment. The root cause of this problem is that the Azure Functions SDK deletes any assembly with a matching name without considering the assembly version. It is necessary to delete the assembly only if it is the same or lower version than the assembly that Functions Runtime has, and not delete it if it is a larger version.