NotSupportedException NotSupportedException NotSupportedException NotSupportedException Class

定義

當不支援叫用的方法,或是嘗試讀取、搜尋或寫入不支援叫用功能的資料流時,所擲回的例外狀況。The exception that is thrown when an invoked method is not supported, or when there is an attempt to read, seek, or write to a stream that does not support the invoked functionality.

public ref class NotSupportedException : SystemException
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class NotSupportedException : SystemException
type NotSupportedException = class
    inherit SystemException
Public Class NotSupportedException
Inherits SystemException
繼承
NotSupportedExceptionNotSupportedExceptionNotSupportedExceptionNotSupportedException
衍生
屬性

備註

NotSupportedException 表示沒有實作存在叫用的方法或屬性。NotSupportedException indicates that no implementation exists for an invoked method or property.

NotSupportedException 會使用 HRESULT COR_E_NOTSUPPORTED,其值 0x80131515。NotSupportedException uses the HRESULT COR_E_NOTSUPPORTED, which has the value 0x80131515.

如需執行個體的初始屬性值的清單NotSupportedException,請參閱NotSupportedException建構函式。For a list of initial property values for an instance of NotSupportedException, see the NotSupportedException constructors.

擲回 NotSupportedException 例外狀況Throwing a NotSupportedException exception

您可以考慮擲回NotSupportedException在下列情況的例外狀況:You might consider throwing a NotSupportedException exception in the following cases:

  • 您要實作的一般用途的介面和方法數目沒有任何有意義的實作。You are implementing a general-purpose interface, and number of the methods have no meaningful implementation. 例如,如果您要建立的日期和時間型別,會實作IConvertible介面,您就會擲回NotSupportedException轉換大部分的例外狀況。For example, if you are creating a date and time type that implements the IConvertible interface, you would throw a NotSupportedException exception for most of the conversions.

  • 您已繼承自抽象類別,需要覆寫的一些方法。You've inherited from an abstract class that requires that you override a number of methods. 不過,您只被準備好提供這些子集的實作。However, you're only prepared to provide an implementation for a subset of these. 對於您決定不要實作方法,您可以選擇要擲回NotSupportedExceptionFor the methods that you decide not to implement, you can choose to throw a NotSupportedException.

  • 您會定義一般用途的型別,有條件地可讓您操作的狀態。You are defining a general-purpose type with a state that enables operations conditionally. 比方說,您的型別可以是唯讀或讀寫。For example, your type can be either read-only or read-write. 在此情況下:In that case:

    • 如果物件是唯讀的試圖將值指派給屬性的修改執行個體狀態執行個體或呼叫方法應該擲回NotSupportedException例外狀況。If the object is read-only, attempting to assign values to the properties of an instance or call methods that modify instance state should throw a NotSupportedException exception.

    • 您應該實作屬性,傳回Boolean值,指出是否有提供特定功能。You should implement a property that returns a Boolean value that indicates whether particular functionality is available. 例如,對於這種類型可以是唯讀或讀寫,您可以實作IsReadOnly屬性,指出是否可以或無法使用一組讀寫的方法。For example, for a type that can be either read-only or read-write, you could implement a IsReadOnly property that indicates whether the set of read-write methods are available or unavailable.

處理 NotSupportedException 例外狀況Handling a NotSupportedException exception

NotSupportedException例外狀況表示一種方法具有沒有實作,而且,您不應該呼叫它。The NotSupportedException exception indicates that a method has no implementation and that you should not call it. 您不應該處理例外狀況。You should not handle the exception. 相反地,該怎麼辦取決於例外狀況的原因: 實作是完全不存在,還是成員引動過程不一致乃物件 (例如呼叫FileStream.Write方法的唯讀FileStream物件.Instead, what you should do depends on the cause of the exception: whether an implementation is completely absent , or the member invocation is inconsistent with the purpose of an object (such as a call to the FileStream.Write method on a read-only FileStream object .

因為有意義的方式,就無法執行此作業,但實作尚未提供。An implementation has not been provided because the operation cannot be performed in a meaningful way.
這是常見的例外狀況,您會在一般用途的介面,提供抽象基底類別或實作的方法實作的物件上呼叫方法時,此方法沒有任何有意義的實作This is a common exception when you are calling methods on an object that provides implementations for the methods of an abstract base class, or that implements a general-purpose interface, and the method has no meaningful implementation.

例如,Convert類別會實作IConvertible介面,這表示它必須包含方法,將每個基本的型別轉換為每個其他基本型別。For example, the Convert class implements the IConvertible interface, which means that it must include a method to convert every primitive type to every other primitive type. 許多這些轉換,不過,不可能。Many of those conversions, however, are not possible. 如此一來,呼叫Convert.ToBoolean(DateTime)方法,比方說,會擲回NotSupportedException例外狀況因為沒有任何可能的轉換之間DateTimeBooleanAs a result, a call to the Convert.ToBoolean(DateTime) method, for instance, throws a NotSupportedException exception because there is no possible conversion between a DateTime and a Boolean value

若要排除例外狀況,您應該刪除方法呼叫。To eliminate the exception, you should eliminate the method call.

方法呼叫不支援指定之物件的狀態。The method call is not supported given the state of the object.
您嘗試叫用的成員,其功能是無法使用,因為物件的狀態。You are attempting to invoke a member whose functionality is unavailable because of the object's state. 您可以排除在三種方式之一的例外狀況:You can eliminate the exception in one of three ways:

  • 您事先知道物件的狀態,但不支援的方法或屬性所叫用。You know the state of the object in advance, but you've invoked an unsupported method or property. 在此案例中,成員引動過程會發生錯誤,而且您也可以將它消除。In this case, the member invocation is an error, and you can eliminate it.

  • 您已經知道物件的狀態 (通常是因為您的程式碼具現化),但該物件是未正確設定。You know the state of the object in advance (usually because your code has instantiated it), but the object is mis-configured. 下列範例說明此問題。The following example illustrates this issue. 它會建立唯讀FileStream物件,然後嘗試寫入其中。It creates a read-only FileStream object and then attempts to write to it.

    using System;
    using System.IO;
    using System.Text;
    using System.Threading.Tasks;
    
    public class Example
    {
       public static async Task Main()
       {
          Encoding enc = Encoding.Unicode;
          String value = "This is a string to persist.";
          Byte[] bytes  = enc.GetBytes(value);
    
          FileStream fs = new FileStream(@".\TestFile.dat", 
                                         FileMode.Open,
                                         FileAccess.Read);
          Task t = fs.WriteAsync(enc.GetPreamble(), 0, enc.GetPreamble().Length);
          Task t2 = t.ContinueWith( (a) => fs.WriteAsync(bytes, 0, bytes.Length) ); 
          await t2;
          fs.Close();
       }
    }
    // The example displays the following output:
    //    Unhandled Exception: System.NotSupportedException: Stream does not support writing.
    //       at System.IO.Stream.BeginWriteInternal(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state
    //    , Boolean serializeAsynchronously)
    //       at System.IO.FileStream.BeginWrite(Byte[] array, Int32 offset, Int32 numBytes, AsyncCallback userCallback, Object sta
    //    teObject)
    //       at System.IO.Stream.<>c.<BeginEndWriteAsync>b__53_0(Stream stream, ReadWriteParameters args, AsyncCallback callback,
    //    Object state)
    //       at System.Threading.Tasks.TaskFactory`1.FromAsyncTrim[TInstance,TArgs](TInstance thisRef, TArgs args, Func`5 beginMet
    //    hod, Func`3 endMethod)
    //       at System.IO.Stream.BeginEndWriteAsync(Byte[] buffer, Int32 offset, Int32 count)
    //       at System.IO.FileStream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
    //       at System.IO.Stream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count)
    //       at Example.Main()
    
    Imports System.IO
    Imports System.Text
    Imports System.Threading.Tasks
    
    Module Example
       Public Sub Main()
          Dim enc As Encoding = Encoding.Unicode
          Dim value As String = "This is a string to persist."
          Dim bytes() As Byte = enc.GetBytes(value)
    
          Dim fs As New FileStream(".\TestFile.dat", 
                                   FileMode.Open,
                                   FileAccess.Read)
          Dim t As Task = fs.WriteAsync(enc.GetPreamble(), 0, enc.GetPreamble().Length)
          Dim t2 As Task = t.ContinueWith(Sub(a) fs.WriteAsync(bytes, 0, bytes.Length)) 
          t2.Wait()
          fs.Close()
       End Sub
    End Module
    ' The example displays the following output:
    '    Unhandled Exception: System.NotSupportedException: Stream does not support writing.
    '       at System.IO.Stream.BeginWriteInternal(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state
    '    , Boolean serializeAsynchronously)
    '       at System.IO.FileStream.BeginWrite(Byte[] array, Int32 offset, Int32 numBytes, AsyncCallback userCallback, Object sta
    '    teObject)
    '       at System.IO.Stream.<>c.<BeginEndWriteAsync>b__53_0(Stream stream, ReadWriteParameters args, AsyncCallback callback,
    '    Object state)
    '       at System.Threading.Tasks.TaskFactory`1.FromAsyncTrim[TInstance,TArgs](TInstance thisRef, TArgs args, Func`5 beginMet
    '    hod, Func`3 endMethod)
    '       at System.IO.Stream.BeginEndWriteAsync(Byte[] buffer, Int32 offset, Int32 count)
    '       at System.IO.FileStream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
    '       at System.IO.Stream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count)
    '       at Example.Main()
    

    您可以避免具現化的物件支援的功能,您想要確保例外狀況。You can eliminate the exception by ensuring that the instantiated object supports the functionality you intend. 下列範例將解決此問題的唯讀FileStream藉由提供正確的引數物件FileStream.FileStream(String, FileMode, FileAccess)建構函式。The following example addresses the problem of the read-only FileStream object by providing the correct arguments to the FileStream.FileStream(String, FileMode, FileAccess) constructor.

  • 您事先不知道物件的狀態和物件不支援特定的作業。You don't know the state of the object in advance, and the object doesn't support a particular operation. 在大部分情況下,該物件應該包含的屬性或方法,指出它是否支援一組特定的作業。In most cases, the object should include a property or method that indicates whether it supports a particular set of operations. 您可以藉由檢查物件的值,並叫用成員,才適合消除例外狀況。You can eliminate the exception by checking the value of the object and invoking the member only if appropriate.

    下列範例會定義DetectEncoding方法會擲回NotSupportedException例外狀況,當它嘗試讀取不支援讀取存取的資料流的開頭。The following example defines a DetectEncoding method that throws a NotSupportedException exception when it attempts to read from the beginning of a stream that does not support read access.

    using System;
    using System.IO;
    using System.Threading.Tasks;
    
    public class Example
    {
       public static async Task Main()
       {
          String name = @".\TestFile.dat";
          var fs = new FileStream(name, 
                                  FileMode.Create,
                                  FileAccess.Write);
             Console.WriteLine("Filename: {0}, Encoding: {1}", 
                               name, await FileUtilities.GetEncodingType(fs));
       }
    }
    
    public class FileUtilities
    {
       public enum EncodingType
       { None = 0, Unknown = -1, Utf8 = 1, Utf16 = 2, Utf32 = 3 }
       
       public async static Task<EncodingType> GetEncodingType(FileStream fs)
       {
          Byte[] bytes = new Byte[4];
          int bytesRead = await fs.ReadAsync(bytes, 0, 4);
          if (bytesRead < 2)
             return EncodingType.None;
          
          if (bytesRead >= 3 & (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF))
             return EncodingType.Utf8;
          
          if (bytesRead == 4) { 
             var value = BitConverter.ToUInt32(bytes, 0);
             if (value == 0x0000FEFF | value == 0xFEFF0000)
                return EncodingType.Utf32;
          }
          
          var value16 = BitConverter.ToUInt16(bytes, 0);
          if (value16 == (ushort)0xFEFF | value16 == (ushort)0xFFFE) 
             return EncodingType.Utf16;
          
          return EncodingType.Unknown;
       }
    }
    // The example displays the following output:
    //    Unhandled Exception: System.NotSupportedException: Stream does not support reading.
    //       at System.IO.FileStream.BeginRead(Byte[] array, Int32 offset, Int32 numBytes, AsyncCallback callback, Object state)
    //       at System.IO.Stream.<>c.<BeginEndReadAsync>b__46_0(Stream stream, ReadWriteParameters args, AsyncCallback callback, Object state)
    //       at System.Threading.Tasks.TaskFactory`1.FromAsyncTrim[TInstance, TArgs](TInstance thisRef, TArgs args, Func`5 beginMethod, Func`3 endMethod)
    //       at System.IO.Stream.BeginEndReadAsync(Byte[] buffer, Int32 offset, Int32 count)
    //       at System.IO.FileStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
    //       at System.IO.Stream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count)
    //       at FileUtilities.GetEncodingType(FileStream fs) in C:\Work\docs\program.cs:line 26
    //       at Example.Main() in C:\Work\docs\program.cs:line 13
    //       at Example.<Main>()
    
    Imports System.IO
    Imports System.Threading.Tasks
    
    Module Example
       Public Sub Main()
          Dim name As String = ".\TestFile.dat"
          Dim fs As New FileStream(name, 
                                   FileMode.Create,
                                   FileAccess.Write)
          Console.WriteLine("Filename: {0}, Encoding: {1}", 
                            name, FileUtilities.GetEncodingType(fs))
       End Sub
    End Module
    
    Public Class FileUtilities
       Public Enum EncodingType As Integer
          None = 0
          Unknown = -1
          Utf8 = 1
          Utf16 = 2
          Utf32 = 3
       End Enum
       
       Public Shared Function GetEncodingType(fs As FileStream) As EncodingType
          Dim bytes(3) As Byte
          Dim t As Task(Of Integer) = fs.ReadAsync(bytes, 0, 4)
          t.Wait()
          Dim bytesRead As Integer = t.Result
          If bytesRead < 2 Then Return EncodingType.None
          
          If bytesRead >= 3 And (bytes(0) = &hEF AndAlso bytes(1) = &hBB AndAlso bytes(2) = &hBF) Then
             Return EncodingType.Utf8
          End If
          
          If bytesRead = 4 Then 
             Dim value As UInteger = BitConverter.ToUInt32(bytes, 0)
             If value = &h0000FEFF Or value = &hFEFF0000 Then
                Return EncodingType.Utf32
             End If
          End If
          
          Dim value16 As UInt16 = BitConverter.ToUInt16(bytes, 0)
          If value16 = &hFEFF Or value16 = &hFFFE Then 
             Return EncodingType.Utf16
          End If
          
          Return EncodingType.Unknown
       End Function
    End Class
    ' The example displays the following output:
    '    Unhandled Exception: System.NotSupportedException: Stream does not support reading.
    '       at System.IO.Stream.BeginReadInternal(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state,
    '     Boolean serializeAsynchronously)
    '       at System.IO.FileStream.BeginRead(Byte[] array, Int32 offset, Int32 numBytes, AsyncCallback userCallback, Object stat
    '    eObject)
    '       at System.IO.Stream.<>c.<BeginEndReadAsync>b__43_0(Stream stream, ReadWriteParameters args, AsyncCallback callback, O
    '    bject state)
    '       at System.Threading.Tasks.TaskFactory`1.FromAsyncTrim[TInstance,TArgs](TInstance thisRef, TArgs args, Func`5 beginMet
    '    hod, Func`3 endMethod)
    '       at System.IO.Stream.BeginEndReadAsync(Byte[] buffer, Int32 offset, Int32 count)
    '       at System.IO.FileStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
    '       at System.IO.Stream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count)
    '       at FileUtilities.GetEncodingType(FileStream fs)
    '       at Example.Main()
    

    您可以藉由檢查的值來消除例外狀況FileStream.CanRead屬性和結束方法,如果資料流是唯讀的。You can eliminate the exception by examining the value of the FileStream.CanRead property and exiting the method if the stream is read-only.

       public static async Task<EncodingType> GetEncodingType(FileStream fs)
       {
          if (!fs.CanRead) 
             return EncodingType.Unknown;
    
          Byte[] bytes = new Byte[4];
          int bytesRead = await fs.ReadAsync(bytes, 0, 4);
          if (bytesRead < 2)
             return EncodingType.None;
          
          if (bytesRead >= 3 & (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF))
             return EncodingType.Utf8;
          
          if (bytesRead == 4) { 
             var value = BitConverter.ToUInt32(bytes, 0);
             if (value == 0x0000FEFF | value == 0xFEFF0000)
                return EncodingType.Utf32;
          }
          
          var value16 = BitConverter.ToUInt16(bytes, 0);
          if (value16 == (ushort)0xFEFF | value16 == (ushort)0xFFFE) 
             return EncodingType.Utf16;
          
          return EncodingType.Unknown;
       }
    }
    // The example displays the following output:
    //       Filename: .\TestFile.dat, Encoding: Unknown
    
    Public Class FileUtilities
       Public Enum EncodingType As Integer
          None = 0
          Unknown = -1
          Utf8 = 1
          Utf16 = 2
          Utf32 = 3
       End Enum
       
       Public Shared Function GetEncodingType(fs As FileStream) As EncodingType
          If Not fs.CanRead Then
             Return EncodingType.Unknown
    
          Dim bytes(3) As Byte
          Dim t As Task(Of Integer) = fs.ReadAsync(bytes, 0, 4)
          t.Wait()
          Dim bytesRead As Integer = t.Result
          If bytesRead < 2 Then Return EncodingType.None
          
          If bytesRead >= 3 And (bytes(0) = &hEF AndAlso bytes(1) = &hBB AndAlso bytes(2) = &hBF) Then
             Return EncodingType.Utf8
          End If
          
          If bytesRead = 4 Then 
             Dim value As UInteger = BitConverter.ToUInt32(bytes, 0)
             If value = &h0000FEFF Or value = &hFEFF0000 Then
                Return EncodingType.Utf32
             End If
          End If
          
          Dim value16 As UInt16 = BitConverter.ToUInt16(bytes, 0)
          If value16 = &hFEFF Or value16 = &hFFFE Then 
             Return EncodingType.Utf16
          End If
          
          Return EncodingType.Unknown
       End Function
    End Class
    ' The example displays the following output:
    '       Filename: .\TestFile.dat, Encoding: Unknown
    

NotSupportedException為兩個其他的例外狀況類型,與密切相關的例外狀況The NotSupportedException exception is closely related to two other exception types;

NotImplementedException.NotImplementedException.
方法可以實作,但不是,會擲回這個例外狀況可能是因為將較新版本中實作的成員、 成員不是可在特定的平台,或該成員所屬的抽象類別和衍生的類別必須提供 implementation。This exception is thrown when a method could be implemented but is not, either because the member will be implemented in a later version, the member is not available on a particular platform, or the member belongs to an abstract class and a derived class must provide an implementation.

InvalidOperationException
在所在通常有時可能會執行要求的作業中,物件的情況下擲回這個例外狀況和狀態物件會判斷是否可以執行這項作業。This exception is thrown in scenarios in which it is generally sometimes possible for the object to perform the requested operation, and the object state determines whether the operation can be performed.

.NET compact Framework 備忘稿.NET Compact Framework notes

.NET Compact Framework.NET Compact Framework 搭配使用,並在原生函式中使用 P/Invoke 時,可能會在下列情況中擲回這個例外狀況:When working with the .NET Compact Framework.NET Compact Framework and using P/Invoke on a native function, this exception may be thrown if:

  • Managed 程式碼中的宣告不正確。The declaration in managed code is incorrect.

  • .NET Compact Framework.NET Compact Framework 不支援您嘗試進行的動作。The .NET Compact Framework.NET Compact Framework does not support what you are trying to do.

  • DLL 名稱在輸出期間損壞。The DLL names are mangled on export.

如果NotSupportedException擲回例外狀況,請檢查:If a NotSupportedException exception is thrown, check:

  • 任何違反 .NET Compact Framework.NET Compact Framework P/Invoke 限制的行為。For any violations of the .NET Compact Framework.NET Compact Framework P/Invoke restrictions.

  • 需要預先配置記憶體的任何引數。For any arguments that require pre-allocated memory. 如果這些引數存在的話,您必須將參考傳遞至現有變數。If these exist, you should pass a reference to an existing variable.

  • 輸出函式的所有名稱都是正確的。That the names of the exported functions are correct. 這可以透過確認DumpBin.exeThis can be verified with DumpBin.exe.

  • 您並未嘗試傳遞過多的引數。That you are not attempting to pass too many arguments.

建構函式

NotSupportedException() NotSupportedException() NotSupportedException() NotSupportedException()

初始化 NotSupportedException 類別的新執行個體,設定該新執行個體的 Message 屬性為描述錯誤的系統提供訊息。Initializes a new instance of the NotSupportedException class, setting the Message property of the new instance to a system-supplied message that describes the error. 此訊息會考量目前的系統文化特性。This message takes into account the current system culture.

NotSupportedException(SerializationInfo, StreamingContext) NotSupportedException(SerializationInfo, StreamingContext) NotSupportedException(SerializationInfo, StreamingContext) NotSupportedException(SerializationInfo, StreamingContext)

使用序列化資料,初始化 NotSupportedException 類別的新執行個體。Initializes a new instance of the NotSupportedException class with serialized data.

NotSupportedException(String) NotSupportedException(String) NotSupportedException(String) NotSupportedException(String)

使用指定的錯誤訊息,初始化 NotSupportedException 類別的新執行個體。Initializes a new instance of the NotSupportedException class with a specified error message.

NotSupportedException(String, Exception) NotSupportedException(String, Exception) NotSupportedException(String, Exception) NotSupportedException(String, Exception)

使用指定的錯誤訊息以及造成此例外狀況的內部例外狀況的參考,初始化 NotSupportedException 類別的新執行個體。Initializes a new instance of the NotSupportedException class with a specified error message and a reference to the inner exception that is the cause of this exception.

屬性

Data Data Data Data

取得提供例外狀況之其他使用者定義相關資訊的索引鍵/值組集合。Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(Inherited from Exception)
HelpLink HelpLink HelpLink HelpLink

取得或設定與這個例外狀況相關聯的說明檔連結。Gets or sets a link to the help file associated with this exception.

(Inherited from Exception)
HResult HResult HResult HResult

取得或設定 HRESULT,它是指派給特定例外狀況的編碼數值。Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(Inherited from Exception)
InnerException InnerException InnerException InnerException

取得造成目前例外狀況的 Exception 執行個體。Gets the Exception instance that caused the current exception.

(Inherited from Exception)
Message Message Message Message

取得描述目前例外狀況的訊息。Gets a message that describes the current exception.

(Inherited from Exception)
Source Source Source Source

取得或設定造成錯誤的應用程式或物件的名稱。Gets or sets the name of the application or the object that causes the error.

(Inherited from Exception)
StackTrace StackTrace StackTrace StackTrace

取得呼叫堆疊上即時運算框架的字串表示。Gets a string representation of the immediate frames on the call stack.

(Inherited from Exception)
TargetSite TargetSite TargetSite TargetSite

取得擲回目前例外狀況的方法。Gets the method that throws the current exception.

(Inherited from Exception)

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetBaseException() GetBaseException() GetBaseException() GetBaseException()

在衍生類別中覆寫時,傳回一或多個後續的例外狀況的根本原因 ExceptionWhen overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

(Inherited from Exception)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

在衍生類別中覆寫時,使用例外狀況的資訊設定 SerializationInfoWhen overridden in a derived class, sets the SerializationInfo with information about the exception.

(Inherited from Exception)
GetType() GetType() GetType() GetType()

取得目前執行個體的執行階段類型。Gets the runtime type of the current instance.

(Inherited from Exception)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

建立並傳回目前例外狀況的字串表示。Creates and returns a string representation of the current exception.

(Inherited from Exception)

事件

SerializeObjectState SerializeObjectState SerializeObjectState SerializeObjectState

當例外狀況序列化,以建立包含例外狀況相關序列化資料的例外狀況狀態物件時,就會發生此事件。Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(Inherited from Exception)

適用於

另請參閱