Bug 35635 - System.TimeZoneInfo not found exception when TimeZone name ends with parenthesys.
Summary: System.TimeZoneInfo not found exception when TimeZone name ends with parenthe...
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 4.0.0
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-11-06 13:52 UTC by Arturo Espinosa
Modified: 2016-03-01 09:11 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

registry file with the tiemzone definition with the modified name (1.05 KB, application/octet-stream)
2015-11-06 13:52 UTC, Arturo Espinosa

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Arturo Espinosa 2015-11-06 13:52:42 UTC
Created attachment 13707 [details]
registry file with the tiemzone definition with the modified name

Running under Windows 10 with a TimeZone of Mexico Central, I get the following dump (cropped):

exception inside UnhandledException handler: (null)

[ERROR] FATAL UNHANDLED EXCEPTION: System.TimeZoneNotFoundException: Exception o
f type 'System.TimeZoneNotFoundException' was thrown.
  at System.TimeZoneInfo.FindSystemTimeZoneById (System.String id) [0x00000] in
<filename unknown>:0
  at System.TimeZoneInfo.CreateLocal () [0x00000] in <filename unknown>:0
  at System.TimeZoneInfo.get_Local () [0x00000] in <filename unknown>:0
  at System.TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc (DateTime time, System.B
oolean& isAmbiguousLocalDst) [0x00000] in <filename unknown>:0
  at System.DateTime.get_Now () [0x00000] in <filename unknown>:0
  at Mono.WebServer.Log.Logger.Write (LogLevel level, System.String message) [0x
00000] in <filename unknown>:0

Reading the code, TimeZoneInfo gets the name of my TimeZone from the registry correctly, which is:

"Central Standard Time (Mexico)"

but then it trims the value from the left and the right, removing any characters that are not letters or digits (System.TimeZoneInfo.TrimSpecial). This eats up the closing parenthesys in the string and so it can't find the timezone from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones

If I create a copy of my timezone under the name "Central Standard Time (Mexico", the timezone is found, no trouble.

I'm attaching the registry file with the tiemzone definition with the modified name.
Comment 1 Arturo Espinosa 2015-11-06 17:55:42 UTC
Pull request:

Comment 2 Alexander Köplinger [MSFT] 2016-03-01 09:11:25 UTC
Fixed with https://github.com/mono/mono/pull/2703. Thanks for the PR!