[.net 6] System.TimeZoneNotFoundException: The time zone ID 'Asia/Almaty' was not found on the local computer.
Yerkon opened this issue · comments
Hello,
After upgrading project from .net 5 to .net 6, error occurs on Windows Server 2019.
`
System.TimeZoneNotFoundException: The time zone ID 'Asia/Almaty' was not found on the local computer.
at System.TimeZoneInfo.FindSystemTimeZoneById(String id)
at Octonica.ClickHouseClient.Utils.TimeZoneHelper.GetTimeZoneInfo(String timeZone)
at Octonica.ClickHouseClient.Types.DateTimeTypeInfo.GetTimeZone()
at Octonica.ClickHouseClient.Types.DateTimeTypeInfo.CreateColumnWriter[T](String columnName, IReadOnlyList1 rows, ClickHouseColumnSettings columnSettings) at Octonica.ClickHouseClient.ClickHouseParameter.ParameterColumnWriterBuilder.Dispatch[T]() at Octonica.ClickHouseClient.Utils.TypeDispatcher.Dispatcher
1.Dispatch[T](ITypeDispatcher1 dispatcher) at Octonica.ClickHouseClient.Utils.TypeDispatcher.Dispatch[TOut](Type type, ITypeDispatcher
1 dispatcher)
at Octonica.ClickHouseClient.ClickHouseParameter.CreateParameterColumnWriter(IClickHouseTypeInfoProvider typeInfoProvider)
at Octonica.ClickHouseClient.ClickHouseCommand.<>c__DisplayClass88_0.b__0(ClickHouseParameter p)
at System.Linq.Enumerable.SelectIListIterator2.ToList() at Octonica.ClickHouseClient.ClickHouseTableWriter..ctor(String tableName, Int32 rowCount, IEnumerable
1 columns)
at Octonica.ClickHouseClient.ClickHouseCommand.CreateParameterTableWriter(IClickHouseTypeInfoProvider typeInfoProvider, String tableName)
at Octonica.ClickHouseClient.ClickHouseCommand.SendQuery(Session session, CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Octonica.ClickHouseClient.ClickHouseCommand.SendQuery(Session session, CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Octonica.ClickHouseClient.ClickHouseCommand.ExecuteDbDataReader(CommandBehavior behavior, Boolean ignoreProfileEvents, Boolean async, CancellationToken cancellationToken)
at Octonica.ClickHouseClient.ClickHouseCommand.ExecuteDbDataReader(CommandBehavior behavior, Boolean ignoreProfileEvents, Boolean async, CancellationToken cancellationToken)
at Octonica.ClickHouseClient.ClickHouseCommand.ExecuteReaderAsync()
at Marketing.Utils.Database.Clickhouse.ClickhouseHelper.<>c__DisplayClass26_0.<b__0>d.MoveNext() in
--- End of stack trace from previous location ---
`
"Octonica.ClickHouseClient" Version="2.2.9"
For "Octonica.ClickHouseClient" Version="2.2.8" the same
But when running locally (Windows 10), it works
I fixed it by forcing local ICU through nuget App-local ICU. Probably, there is no ICU installed on Windows server 2019
I have the same problem on Windows 10 with " System.TimeZoneNotFoundException: The time zone ID 'Europe/Berlin' was not found on the local computer.".
@Yerkon How did you solve the problem? I added the following lines in my .csproj file, but I still get the error.
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="72.1.0.3" />
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="72.1.0.3" />
</ItemGroup>
@MrDoe, only include in Windows platform:
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9"/>
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2"/>
</ItemGroup>
Also, in program you can check if IcuMode enabled with method:
private static bool IcuMode()
{
SortVersion sortVersion = CultureInfo.InvariantCulture.CompareInfo.Version;
byte[] bytes = sortVersion.SortId.ToByteArray();
int version = (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0];
return version != 0 && version == sortVersion.FullVersion;
}
@Yerkon Thanks for your answer! I tried this, the IcuMode works, but I still get the error. Maybe it is an issue with .NET 8 running on Windows 10.
I debugged the library and changed
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static partial void GetTimeZoneInfoImpl(string timeZone, ref TimeZoneInfo? timeZoneInfo)
{
timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZone);
}
to
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static partial void GetTimeZoneInfoImpl(string timeZone, ref TimeZoneInfo? timeZoneInfo)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
timeZone = TZConvert.IanaToWindows(timeZone);
}
timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZone);
}
in TimeZoneHelper.Net6.0.cs.
Now it works, but I get another error: ""TODO: add support for custom serialization."
But I guess this is another issue. Do you know by chance what "custom serialization" means?
The error is occuring when I try to select a DateTime64 column. As a workaround, I'm currently using toString(myDateTime64Column)
in my queries.
@MrDoe, maybe @victor-sushko will help?
Now it works, but I get another error: ""TODO: add support for custom serialization." But I guess this is another issue. Do you know by chance what "custom serialization" means?
The error is occuring when I try to select a DateTime64 column. As a workaround, I'm currently using
toString(myDateTime64Column)
in my queries.
In recent versions ClickHouse "breaks" wire protocol.
You can disable sparse columns feature or wait for release with sparse column see #85 (couple of days)