Using VS2019 I have generated an Azure Function project. The Azure function is triggered by an HTTP request to convert CSV content to an XLSX file using EPPlus.
The code is really really simple:
[FunctionName("Function1")]
public static async Task<IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log)
{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
// line below will raise "System.Text.Encoding.CodePages.dll" not found exception
ExcelPackage xcel = new ExcelPackage();
// ... some other code
}
The ExcelPackage instanciation will raise the following error: "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." EPPlus is relying System.Text.Encoding.CodePages 5.0.0.0 but looks like .Net core 3.1 is relying on a 4.x version.
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 unsatisfactory because every time I am rebuilding the solution, I have to deploy the System.Text.Encoding.CodePage.dll manually.
I have tried different things I read about binding redirect but unsuccessfully. Not very surprising as binding redirect is more .net framework related.
This drives me nuts.