InvalidTimeZoneException Konstruktoren

Definition

Initialisiert eine neue Instanz der InvalidTimeZoneException-Klasse.

Überlädt

InvalidTimeZoneException()

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

InvalidTimeZoneException(String)

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

InvalidTimeZoneException(SerializationInfo, StreamingContext)
Veraltet.

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

InvalidTimeZoneException(String, Exception)

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

InvalidTimeZoneException()

Quelle:
InvalidTimeZoneException.cs
Quelle:
InvalidTimeZoneException.cs
Quelle:
InvalidTimeZoneException.cs

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

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

Hinweise

Dies ist der parameterlose Konstruktor der InvalidTimeZoneException -Klasse. Die -Eigenschaft des neuen instance wird in einer vom System bereitgestellten Meldung initialisiertMessage, die den Fehler beschreibt, z. B. "Ausnahme vom Typ 'System.InvalidTimeZoneException' wurde ausgelöst." Diese Meldung wird für die aktuelle Systemkultur lokalisiert.

Gilt für:

InvalidTimeZoneException(String)

Quelle:
InvalidTimeZoneException.cs
Quelle:
InvalidTimeZoneException.cs
Quelle:
InvalidTimeZoneException.cs

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

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

Parameter

message
String

Eine Zeichenfolge, die die Ausnahme beschreibt.

Hinweise

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

Gilt für:

InvalidTimeZoneException(SerializationInfo, StreamingContext)

Quelle:
InvalidTimeZoneException.cs
Quelle:
InvalidTimeZoneException.cs
Quelle:
InvalidTimeZoneException.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 InvalidTimeZoneException-Klasse.

protected:
 InvalidTimeZoneException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected InvalidTimeZoneException (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 InvalidTimeZoneException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new InvalidTimeZoneException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> InvalidTimeZoneException
[<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 InvalidTimeZoneException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> InvalidTimeZoneException
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 InvalidTimeZoneException Objekt zu instanziieren. Stattdessen wird es von der IFormatter -Methode des Deserialize Objekts aufgerufen, wenn das InvalidTimeZoneException Objekt aus einem Stream deserialisiert wird.

Gilt für:

InvalidTimeZoneException(String, Exception)

Quelle:
InvalidTimeZoneException.cs
Quelle:
InvalidTimeZoneException.cs
Quelle:
InvalidTimeZoneException.cs

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

public:
 InvalidTimeZoneException(System::String ^ message, Exception ^ innerException);
public InvalidTimeZoneException (string message, Exception innerException);
public InvalidTimeZoneException (string? message, Exception? innerException);
new InvalidTimeZoneException : string * Exception -> InvalidTimeZoneException
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

Der folgende Code versucht, ein TimeZoneInfo -Objekt abzurufen, das die zentrale Standardzeitzone darstellt. Wenn im RetrieveTimeZone Methodenaufruf ein InvalidTimeZoneException auftritt, umschließt der Ausnahmehandler die Ausnahme in ein neues InvalidTimeZoneException Objekt, das an den Aufrufer zurückgegeben wird. Der Ausnahmehandler des Aufrufers zeigt dann Informationen zu den äußeren und inneren Ausnahmen 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); 
   }      
}
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 Überladung der InvalidTimeZoneException -Klasse, 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 InvalidTimeZoneException -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: