TimeZoneNotFoundException Class
The exception that is thrown when a time zone cannot be found.
Assembly: System.Core (in System.Core.dll)
Note: |
|---|
The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: MayLeakOnAbort. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes. |
This exception is thrown by the ConvertTimeBySystemTimeZoneId and FindSystemTimeZoneById methods when a time zone identifier cannot be found on the local system, or when there is no data associated with a particular time zone identifier.
Because the registry serves as the repository of time zone information in Windows XP and Windows Vista, this exception indicates that the registry contains no information about a particular time zone. Time zone information is stored in the subkeys of HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Time Zones.
If an application depends on the presence of a particular time zone and the attempt to retrieve it throws a TimeZoneNotFoundException, the application can handle the exception in either of two ways:
By calling the FromSerializedString method to deserialize a saved TimeZoneInfo object.
By calling one of the overloads of the CreateCustomTimeZone method to create a time zone.
See the examples for the TimeZoneInfo.CreateCustomTimeZone(String, TimeSpan, String, String, String, TimeZoneInfo.AdjustmentRule(), Boolean) and FromSerializedString methods.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: