We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Alpine linux container gives System.Globalization.CultureNotFoundException: Culture is not supported

When creating an Alpine based image, as described by you here:
https://docs.aspose.com/display/wordsnet/How+to+Run+Aspose.Words+in+Docker

Most of the products work, but Cells give this error:
System.Globalization.CultureNotFoundException: Culture is not supported. (Parameter ‘culture’)\n1044 (0x0414) is an invalid culture identifier.

Please note that Alpine does not install any cultures by default.
In my Dockerfile I set this:
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
This is as suggested by microsoft.

If I try to install icu_libs and set ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false (could have been an acceptable workaround, but prefer not doing this) it still does not work, and now gives a new error message:
Aspose.Cells.CellsException: The type initializer for ' ’ threw an exception.\n at Aspose.Cells.Workbook.Save(String fileName, SaveOptions saveOptions)\n

@mga,
Thank you for your query.

We have analysed your issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNETCORE-47 – CultureNotFoundException while reading XLS file in .NET Core 3.1 applications

@mga,

We have tested and found Asp.NetCore does not support some of the culture id, for example:

CultureInfo cl = new CultureInfo(1043 & 0xFFFF, true);

This code will return a “nl-NL” culture in .NETCore, but will get an error in Asp.NetCore.
To solve this problem we have provided a solution in Aspose.Cells for .NET v20.1 (latest version).

//First, declare a class in your code:
class CustomImp : Aspose.Cells.CustomImplementationFactory {
public override System.Globalization.CultureInfo CreateCultureInfo(int lcid) {
try {
return new CultureInfo(lcid);
}
catch {
//You may modify this, implemment your culture here when exception occurs in asp.netcore
return CultureInfo.CurrentCulture;
}
}
}
//do the CustomImplementationFactory assignment before you open a workbook
Aspose.Cells.CellsHelper.CustomImplementationFactory = new CustomImp();

Please declare a class like this and do the CustomImplementationFactory assignment before you open a workbook. You may get Aspose.Cells 20.1 version from nuget repos here, We also provided an example in the test project: TestAsposeCellsInWebApi.

Hello. Thank you for this fix. I have tested and verified the suggested code fixes my issue.

@mga,

Good to know that your issue is sorted out by the new fix and suggested code. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.