-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TimeZoneNotFoundException: The time zone ID 'America/Chicago' was not found on the local computer. #60175
Comments
Is this error being thrown by .NET Core or WebAssembly? |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
This happens on the server(in the controller).Nothing to do with wash, other that it a Blazor wasm hosted project.
Sent from Yahoo Mail for iPhone
On Friday, October 8, 2021, 8:14 AM, Pranav K ***@***.***> wrote:
Is this error being thrown by .NET Core or WebAssembly?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
Here is the GitHub repo |
@nssidhu is that a private repo? the link gives 404. I think all we need is the snippet of code, the value you're passing to the API, and any details of your configuration (sounds like .NET 6.0 RC1 on Windows?) |
It is very simple to reproduce, Just create a Blazor wasm hosted sample app. Can't be any simpler than this.
|
I have changed the visibility to public |
Yes it is using .NET 6 RC1. C:\Users\admin>dotnet --info Runtime Environment: Host (useful for support): .NET SDKs installed: .NET runtimes installed: To install additional .NET runtimes or SDKs: |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsI am using .NET RC1 Blazor WebAssembly Hosted App. In my Server Controller, i am trying to find the Timezone of business location as shown below.
but i get the following error.
|
Ah - I missed that it was Blazor. @lewing I know we do special time zone things on Blazor..? |
Again, I am talking about Blazor server side error and not client(wasm), I just happen to use Blazor wasm hosted project. |
According to this SO question, Azure AppService uses the NLS globalization mode. That would explain this issue since support for IANA time zone IDs does not work in the NLS mode: runtime/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.FullGlobalizationData.cs Lines 10 to 16 in 3de6207
An answer to that question suggest using app local ICU to disable the NLS mode. |
@tarekgh I wonder whether we should suggest to AppService that they move to ICU default, at least perhaps for 6.0+. |
great find @svick BTW thank you. |
Tagging subscribers to this area: @dotnet/area-system-runtime Issue DetailsI am using .NET RC1 Blazor WebAssembly Hosted App. In my Server Controller, i am trying to find the Timezone of business location as shown below.
but i get the following error.
|
I am not clear here what OS used to run the WASM server? Does WASM server is running with Azure AppService? Answers may help here. Some Windows Servers OS's doesn't have ICU versions (or has old ICU versions which .NET doesn't support). If running on such environment, the workaround is to use ICU app-local feature. Add something like the following to the csproj: <ItemGroup>
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.6" />
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.6" />
</ItemGroup> If the users have no control and Azure AppService is controlling using NLS or ICU, then the solution must come from Azure AppService to allow using ICU. @lewing may know better how the WASM server run using Azure AppService. We'll need to understand too why Azure AppServer decided to force NLS mode too. @danmoseley can you connect us with somebody from Azure side? |
The error is occurring in is .NET 6 server side. It has nothing to do with wasm. I tried those settings in the separate isolated repo and it seems to work. I am now trying to snap shot debug azure deployed app to see what is happening on the server side, will update Found out that TimeZoneInfo.ConvertTimeFromUtc returns datetime without timezone info, its Quite weird since we are working with timezone it should return DateTimeoffset instead of DateTime. I am not sure why that works correctly on my local pc. |
Are you running the published version on the same machine you are developing on? This was my question about what OS the server code is running on.
Were you running exact same type of project in the isolated repo? and you were running it on the exact same environment?
Thanks, that will help. Please ensure getting the OS version running the server.
TimeZoneInfo.ConvertTimeFromUtc takes the time zone object which the time to. So, you already have all information you need there. Also, you can just use the following API if you need to get DateTimeOffset. public static DateTimeOffset ConvertTime (DateTimeOffset dateTimeOffset, TimeZoneInfo destinationTimeZone);
It is possible the server is running on OS doesn't support ICU which cause the .NET to fallback to NLS. |
I am finding that I cannot use snapshot debugger on Azure App service with visual Studio 2022, it only supports 2017 & 2019. Details about OS and dotnet version are mentioned up in the chain. Will post more details once i have them. |
Some more findings Here is the code which is running into problem when deployed on to Azure App Service(Windows) as self contained.
|
works after deploying on the new instance of Azure app service. |
@nssidhu thanks for your tries and investigation. Just to know, what extra thing you did to make it work when you have a clean reinstall on Azure app service? did you reference the ICU package in your project? |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsI am using .NET RC1 Blazor WebAssembly Hosted App. In my Server Controller, i am trying to find the Timezone of business location as shown below.
but i get the following error.
|
@lewing could you please have a look? when running WASM server app from VS or when deploying it to local folder, everything works fine as expected. When deploying the app to Azure app service it doesn't work. Looking at the deployment log (from the video) it shows first the app get trimmed then |
@tarekgh I suspect something wrong in the routing framework when deployed on Azure app service. I updated my code to have swagger and i cannot even open swagger on the deployed version. Somehow i am getting feeling that Blazor wasm is very unstable platform. thing works fine when running locally and behaves totally different when deployed to Azure App Service. I did open another issue on GitHub for the same source code citing why my API calls are not going through on the deployed vversion. |
This still doesn't look wasm related. @pranavkm any thoughts? or suggestions on who to talk to on the app service side? |
I am having a similar issue with GitHub actions running my unit tests on Windows.
The code is just
You can see in the trace that it's effectively running in .NET 6 so I don't expect it to fail. I have the same tests for net5.0 but using the TimeZoneConverter library, and this works fine. My goal is to remove this dependency when targeting net6.0. System information: Local machine:
GitHub agent:
I don't I should rely on the feature if it can break when running a not so recent OS version. I confirm that adding the ICU package fixes the issue, though it's not ideal. |
The "Windows-latest" VM in GitHub actions is:
Well it is ideal if you want to control the version of ICU you depend on and you don't want to rely on OS environments and want to control that stability. I see that github actions has a |
@nssidhu by any chance could you share a .zip with the published app layout that is running on Azure App Services? |
I don't really care about mitigating the CI issues. Now that I know that it can "randomly" not work on some customers' machines I don't think I want to use the feature. That's not something that a library can enforce. |
Yeah I totally get that and makes sense. That was the intent of the app local feature. The downside is that an app switch needs to be set. I don't know if from a library it could be set early enough before globalization is enabled. Maybe you can instead of stripping the feature out limit it to non windows and windows equals or later than 1903? |
It is up to you to decide to use the feature or not, but I wouldn't suggest not using it. Instead, you can have a fallback mechanism when the API returns false to you. The app author/user is in control. If the NLS mode is used, it is expected to have some limitations. That is why the APIs pattern is returning bool and the callers can decide the fallback they decide to go with. I am expecting in the near future very few users will be using NLS mode. We are already discouraging users from enabling it and using ICU app-local feature when ICU is not available. If you use the feature, you'll be covering most of the users. Now to focus on the original issue that @nssidhu has, @pranavkm is going to look at the deployment of the app to Azure app service and will get back to us. |
@nssidhu looks like Azure App Services will url decode all incoming routes. In your case, this results in the app selecting the fallback route because there isn't a route that matches - [Route("GetTimeZonetime/{TimeZone}")]
+ [Route("GetTimeZonetime/{**TimeZone}")]
[HttpGet]
public IActionResult GetTimeZonetime(string TimeZone) |
@tarekhgh
I am vacationing and won’t get chance until Nov 28th.
Also on the other thread someone replied that the problem is because App Sevice auto decode url and then since it does not match with anything it falls back to index.html.
That kind of make sense, but I also ran into issue that even swagger is not working.
Will give a try after I come back from vacation.
Sent from Yahoo Mail for iPhone
On Friday, November 19, 2021, 12:13 PM, Santiago Fernandez Madero ***@***.***> wrote:
@tarekgh I suspect something wrong in the routing framework when deployed on Azure app service. I updated my code to have swagger and i cannot even open swagger on the deployed version.
@nssidhu by any chance could you share a .zip with the published app layout that is running on Azure App Services?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
The issue was due to Routing. Azure App Service runs IIS as a Web Server. When Developing locally Kestrel is the default web server. The problem was occurring because on Azure App Service, which run IIS, automatically decodes the encoded url and than it cannot find the route, after auto decoding the route becomes GetTimeZone/America/chicago, which does not exists. The solution was to update the server controller methods signature to use asterisk(*) and it works, but this is somewhat dangerous option. The proper way should be to pass the timezone in post instead of get request. Original which was running into problem
[Route("GetTimeZonetime/{*TimeZone}")]
|
I am using .NET RC1 Blazor WebAssembly Hosted App.
In my published app to Azure AppService(windows) which is deployed as self-contained i am running into timezone error.
The app works fine when running on my local dev box
In my Server Controller, i am trying to find the Timezone of business location as shown below.
var timezoneLocation = TimeZoneInfo.FindSystemTimeZoneById(LocalTimeAtOrgLocation);
but i get the following error.
The text was updated successfully, but these errors were encountered: