TimeZoneNotFoundException Konstruktoren

Definition

Initialisiert eine neue Instanz der TimeZoneNotFoundException-Klasse.

Überlädt

TimeZoneNotFoundException()

Initialisiert eine neue Instanz der TimeZoneNotFoundException-Klasse mit einer vom System generierten Meldung.

TimeZoneNotFoundException(String)

Initialisiert eine neue Instanz der TimeZoneNotFoundException-Klasse mit der angegebenen Meldungszeichenfolge.

TimeZoneNotFoundException(SerializationInfo, StreamingContext)
Veraltet.

Initialisiert anhand von serialisierten Daten eine neue Instanz der TimeZoneNotFoundException-Klasse.

TimeZoneNotFoundException(String, Exception)

Initialisiert eine neue Instanz der TimeZoneNotFoundException-Klasse mit einer angegebenen Fehlermeldung und einem Verweis auf die innere Ausnahme, die diese Ausnahme ausgelöst hat.

TimeZoneNotFoundException()

Quelle:
TimeZoneNotFoundException.cs
Quelle:
TimeZoneNotFoundException.cs
Quelle:
TimeZoneNotFoundException.cs

Initialisiert eine neue Instanz der TimeZoneNotFoundException-Klasse mit einer vom System generierten Meldung.

public:
 TimeZoneNotFoundException();
public TimeZoneNotFoundException ();
Public Sub New ()

Hinweise

Dies ist der parameterlose Konstruktor der TimeZoneNotFoundException -Klasse. Dieser Konstruktor initialisiert die Message -Eigenschaft des neuen instance in einer vom System bereitgestellten Meldung, die den Fehler beschreibt, z. B. "Die Zeitzone 'timeZoneName' wurde auf dem lokalen Computer nicht gefunden." Diese Meldung wird für die aktuelle Systemkultur lokalisiert.

Gilt für:

TimeZoneNotFoundException(String)

Quelle:
TimeZoneNotFoundException.cs
Quelle:
TimeZoneNotFoundException.cs
Quelle:
TimeZoneNotFoundException.cs

Initialisiert eine neue Instanz der TimeZoneNotFoundException-Klasse mit der angegebenen Meldungszeichenfolge.

public:
 TimeZoneNotFoundException(System::String ^ message);
public TimeZoneNotFoundException (string? message);
public TimeZoneNotFoundException (string message);
new TimeZoneNotFoundException : string -> TimeZoneNotFoundException
Public Sub New (message As String)

Parameter

message
String

Eine Zeichenfolge, die die Ausnahme beschreibt.

Hinweise

Die message Zeichenfolge wird der Message -Eigenschaft zugewiesen. Die Zeichenfolge sollte für die aktuelle Kultur lokalisiert werden.

Gilt für:

TimeZoneNotFoundException(SerializationInfo, StreamingContext)

Quelle:
TimeZoneNotFoundException.cs
Quelle:
TimeZoneNotFoundException.cs
Quelle:
TimeZoneNotFoundException.cs

Achtung

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Initialisiert anhand von serialisierten Daten eine neue Instanz der TimeZoneNotFoundException-Klasse.

protected:
 TimeZoneNotFoundException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected TimeZoneNotFoundException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected TimeZoneNotFoundException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new TimeZoneNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> TimeZoneNotFoundException
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new TimeZoneNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> TimeZoneNotFoundException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parameter

info
SerializationInfo

Das Objekt, das die serialisierten Daten enthält.

context
StreamingContext

Der Datenstrom, der die serialisierten Daten enthält.

Attribute

Ausnahmen

Der info-Parameter ist null.

- oder -

Der context-Parameter ist null.

Hinweise

Dieser Konstruktor wird nicht direkt vom Code aufgerufen, um das TimeZoneNotFoundException Objekt zu instanziieren. Stattdessen wird es von der IFormatter -Methode des Deserialize Objekts aufgerufen, wenn das TimeZoneNotFoundException Objekt aus einem Stream deserialisiert wird.

Gilt für:

TimeZoneNotFoundException(String, Exception)

Quelle:
TimeZoneNotFoundException.cs
Quelle:
TimeZoneNotFoundException.cs
Quelle:
TimeZoneNotFoundException.cs

Initialisiert eine neue Instanz der TimeZoneNotFoundException-Klasse mit einer angegebenen Fehlermeldung und einem Verweis auf die innere Ausnahme, die diese Ausnahme ausgelöst hat.

public:
 TimeZoneNotFoundException(System::String ^ message, Exception ^ innerException);
public TimeZoneNotFoundException (string? message, Exception? innerException);
public TimeZoneNotFoundException (string message, Exception innerException);
new TimeZoneNotFoundException : string * Exception -> TimeZoneNotFoundException
Public Sub New (message As String, innerException As Exception)

Parameter

message
String

Eine Zeichenfolge, die die Ausnahme beschreibt.

innerException
Exception

Die Ausnahme, die die Ursache der aktuellen Ausnahme ist.

Beispiele

Im folgenden Beispiel wird versucht, eine nicht vorhandene Zeitzone abzurufen, wodurch eine TimeZoneNotFoundExceptionausgelöst wird. Der Ausnahmehandler umschließt die Ausnahme in ein neues TimeZoneNotFoundException Objekt, das der Ausnahmehandler an den Aufrufer zurückgibt. Der Ausnahmehandler des Aufrufers zeigt dann Informationen zur äußeren und inneren Ausnahme an.

private void HandleInnerException()
{   
   string timeZoneName = "Any Standard Time";
   TimeZoneInfo tz;
   try
   {
      tz = RetrieveTimeZone(timeZoneName);
      Console.WriteLine("The time zone display name is {0}.", tz.DisplayName);
   }
   catch (TimeZoneNotFoundException e)
   {
      Console.WriteLine("{0} thrown by application", e.GetType().Name);
      Console.WriteLine("   Message: {0}", e.Message);
      if (e.InnerException != null)
      {
         Console.WriteLine("   Inner Exception Information:");
         Exception innerEx = e.InnerException;
         while (innerEx != null)
         {
            Console.WriteLine("      {0}: {1}", innerEx.GetType().Name, innerEx.Message);
            innerEx = innerEx.InnerException;
         }
      }            
   }   
}

private TimeZoneInfo RetrieveTimeZone(string tzName)
{
   try
   {
      return TimeZoneInfo.FindSystemTimeZoneById(tzName);
   }   
   catch (TimeZoneNotFoundException ex1)
   {
      throw new TimeZoneNotFoundException( 
            String.Format("The time zone '{0}' cannot be found.", tzName), 
            ex1);
   }          
   catch (InvalidTimeZoneException ex2)
   {
      throw new InvalidTimeZoneException( 
            String.Format("The time zone {0} contains invalid data.", tzName), 
            ex2); 
   }      
}
open System

let retrieveTimeZone tzName =
    try
        TimeZoneInfo.FindSystemTimeZoneById tzName
    with 
    | :? TimeZoneNotFoundException as ex1 ->
        raise (TimeZoneNotFoundException($"The time zone '{tzName}' cannot be found.", ex1) )
    | :? InvalidTimeZoneException as ex2 ->
        raise (InvalidTimeZoneException($"The time zone {tzName} contains invalid data.", ex2) )

let handleInnerException () =
    let timeZoneName = "Any Standard Time"
    try
        let tz = retrieveTimeZone timeZoneName
        printfn $"The time zone display name is {tz.DisplayName}."
    with :? TimeZoneNotFoundException as e ->
        printfn $"{e.GetType().Name} thrown by application"
        printfn $"   Message: {e.Message}" 
        if e.InnerException <> null then
            printfn "   Inner Exception Information:"
            let rec printInner (innerEx: exn) =
                if innerEx <> null then
                    printfn $"      {innerEx.GetType().Name}: {innerEx.Message}"
                    printInner innerEx.InnerException
            printInner e
Private Sub HandleInnerException()
   Dim timeZoneName As String = "Any Standard Time"
   Dim tz As TimeZoneInfo
   Try
      tz = RetrieveTimeZone(timeZoneName)
      Console.WriteLine("The time zone display name is {0}.", tz.DisplayName)
   Catch e As TimeZoneNotFoundException
      Console.WriteLine("{0} thrown by application", e.GetType().Name)
      Console.WriteLine("   Message: {0}", e.Message)
      If e.InnerException IsNot Nothing Then
         Console.WriteLine("   Inner Exception Information:")
         Dim innerEx As Exception = e.InnerException
         Do
            Console.WriteLine("      {0}: {1}", innerEx.GetType().Name, innerEx.Message)
            innerEx = innerEx.InnerException
         Loop While innerEx IsNot Nothing
      End If            
   End Try   
End Sub

Private Function RetrieveTimeZone(tzName As String) As TimeZoneInfo
   Try
      Return TimeZoneInfo.FindSystemTimeZoneById(tzName)
   Catch ex1 As TimeZoneNotFoundException
      Throw New TimeZoneNotFoundException( _
            String.Format("The time zone '{0}' cannot be found.", tzName), _
            ex1) 
   Catch ex2 As InvalidTimeZoneException
      Throw New InvalidTimeZoneException( _
            String.Format("The time zone {0} contains invalid data.", tzName), _
            ex2) 
   End Try      
End Function

Hinweise

In der Regel verwenden Sie diese TimeZoneNotFoundException Überladung, um eine Ausnahme in einem try...catch Block. Der innerException Parameter sollte ein Verweis auf das Ausnahmeobjekt sein, das catch im -Block behandelt wird, oder er kann sein null. Dieser Wert wird dann der TimeZoneNotFoundException -Eigenschaft des InnerException Objekts zugewiesen.

Die message Zeichenfolge wird der Message -Eigenschaft zugewiesen. Die Zeichenfolge sollte für die aktuelle Kultur lokalisiert werden.

Gilt für: