0

我正在开发一个 .net 核心控制台应用程序,该应用程序使用 Entity Framework Core 与位于本地的 Linux 的 SQL 服务器交互。

当我运行应用程序时,我收到如下所示的错误。

Process terminated. Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.

然后我将环境添加到以下导出

export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
Unhandled exception. System.AggregateException: One or more errors occurred. (Globalization Invariant Mode is not supported.)
 ---> System.NotSupportedException: Globalization Invariant Mode is not supported.
   at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at Microsoft.Data.SqlClient.SqlConnection.OpenAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync(Boolean errorsExpected, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync(Boolean errorsExpected, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
   at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
   at advance_generics.part.one.Program.CountEmployees(IRepository`1 employeeRepo) in /home/bhaskar/C_Sharp_basics/advance_generics/Program.cs:line 24
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at advance_generics.part.one.Program.Main(String[] args) in /home/bhaskar/C_Sharp_basics/advance_generics/Program.cs:line 15

任何机构都可以帮助我吗?

我对ICU做了以下事情

 dpkg --status icu-devtools
Package: icu-devtools
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 678
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Multi-Arch: foreign
Source: icu
Version: 66.1-2ubuntu2
Replaces: icu-tools (<< 66.1-1~), libicu-dev (<< 66.1-2ubuntu2)
Depends: libc6 (>= 2.14), libgcc-s1 (>= 3.0), libicu66 (>= 66.1-1~), libstdc++6 (>= 5.2)
Breaks: icu-tools (<< 66.1-1~), libicu-dev (<< 66.1-2ubuntu2)
Description: Development utilities for International Components for Unicode
 ICU is a C++ and C library that provides robust and full-featured
 Unicode and locale support. This package contains programs used to
 manipulate data files found in the ICU sources and is a dependency of
 libicu-dev.  End users would generally not need to install this package.
Homepage: http://www.icu-project.org
Original-Maintainer: Laszlo Boszormenyi (GCS) <gcs@debian.org>

如果我在 debug 或 Run without debug 模式下运行,则不会遇到问题 我没有收到错误

4

1 回答 1

0

根据icu软件包版本66.1-2ubuntu2,我认为您正在运行 Ubuntu 20.04。

如果这是真的,这是 .NET Core 和 Ubuntu 20.04 之间的不兼容:https ://github.com/dotnet/core/issues/4360 。

确实,这是 .NET Core 开发人员的错误。您无能为力来解决此问题。但是您可以应用一些变通方法来避免该问题。

最常见的似乎是以下。需要强调的是,这是一种解决方法。可能还可以,暂时用于开发环境。这对于生产环境来说不是一个好主意

sudo apt-add-repository 'deb http://archive.ubuntu.com/ubuntu/ eoan main restricted'
sudo apt-get update
sudo apt-get install libicu63

但是,在我看来,更好的选择是坚持使用较低版本的 Ubuntu,例如 19.10,而不是使用 .NET Core 不兼容的 20.04。

于 2020-05-09T18:12:03.367 回答