【问题标题】:Invariant culture issue while running the dotnet 6 application in a Docker Container在 Docker 容器中运行 dotnet 6 应用程序时出现不变文化问题
【发布时间】:2022-12-28 19:48:26
【问题描述】:

我已将 dotnet 应用程序从 Dotnet Core 3.1 升级到 Dotnet 6。升级后出现此错误:

Microsoft.Azure.Storage.StorageException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
en-US is an invalid culture identifier.
 ---> System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')

为了解决这个问题,我发现我们可以尝试在 csproj 中设置 InvariantGlobalization as false,在 docker 中我们可以设置 ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false。但是当我进行这些更改并重新运行应用程序时,我收到另一个错误提示:

Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. Please see https://aka.ms/dotnet-missing-libicu for more information.
   at System.Environment.FailFast(System.String)

修复这些建议与我修复不变文化(第一期)所做的相反。有人可以帮我解决这个问题吗?

我的泊坞窗文件看起来像:

FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine3.14
LABEL pipelineName="somedummyapplication" \
      pipelineKey="DSENJRNF" \
      offeringKey="UQWHCLRA"
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
RUN echo 'http://dl-3.alpinelinux.org/alpine/v3.16/main' >> /etc/apk/repositories 
RUN apk upgrade && apk add sqlite && apk add krb5
EXPOSE 5000
ENV ASPNETCORE_URLS=http://*:5000
WORKDIR /app
COPY . /app
USER guest
ENTRYPOINT ["dotnet", "abc.somedummyapplication.dll"]

我已经检查并尝试这些链接来解决问题,但正如我所说,如果我解决另一个问题出现:Running .NET 6 project in Docker throws Globalization.CultureNotFoundExceptionProcess terminated. Couldn't find a valid ICU package installed on the system in Asp.Net Core 3 - ubuntu

【问题讨论】:

    标签: c# asp.net .net docker .net-core


    【解决方案1】:

    基于Alpine的镜像不包含ICU,需要手动安装:

    apk add icu-data-full icu-libs
    

    您可能还会遇到与 TimeZoneInfo.FindSystemTimeZoneById 类似的问题,因为基于 Alpine 的图像不包括 tzdb:

    apk add tzdata
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-02
      • 1970-01-01
      • 2020-11-07
      • 2021-11-29
      • 1970-01-01
      • 1970-01-01
      • 2019-01-14
      • 1970-01-01
      相关资源
      最近更新 更多