Разработка ядра. Net в Ubuntu с использованием VS Code - PullRequest
0 голосов
/ 09 мая 2020

Я разрабатываю консольное приложение. net core, в котором приложение взаимодействует с SQL сервером для Linux, расположенным локально, с использованием Entity Framework Core.

Когда я запускаю приложение, я получаю ошибка, показанная ниже.

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>

Проблема не возникает, если я запускаю в режиме отладки или Запуск без отладки. Я не получаю сообщение об ошибке

1 Ответ

0 голосов
/ 09 мая 2020

Основываясь на версии пакета 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. использования 20.04, что. NET Core не совместим с.

...