ArgumentNullException クラス
定義
null 参照 (Visual Basic では Nothing
) を有効な引数として受け付けないメソッドに null 参照を渡した場合にスローされる例外。The exception that is thrown when a null reference (Nothing
in Visual Basic) is passed to a method that does not accept it as a valid argument.
public ref class ArgumentNullException : ArgumentException
public class ArgumentNullException : ArgumentException
[System.Serializable]
public class ArgumentNullException : ArgumentException
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class ArgumentNullException : ArgumentException
type ArgumentNullException = class
inherit ArgumentException
[<System.Serializable>]
type ArgumentNullException = class
inherit ArgumentException
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ArgumentNullException = class
inherit ArgumentException
Public Class ArgumentNullException
Inherits ArgumentException
- 継承
- 継承
- 属性
注釈
ArgumentNullException例外は、メソッドが呼び出され、渡された引数の少なくとも1つがの場合にスローされますが、に null
することはできません null
。An ArgumentNullException exception is thrown when a method is invoked and at least one of the passed arguments is null
but should never be null
.
ArgumentNullException次の2つの主要な状況では、例外が実行時にスローされます。どちらも開発者エラーを反映しています。An ArgumentNullException exception is thrown at run time in the following two major circumstances, both of which reflect developer error:
インスタンスオブジェクトがメソッドに渡されます。An uninstantiated object is passed to a method. このエラーを回避するには、オブジェクトをインスタンス化します。To prevent the error, instantiate the object.
メソッドの呼び出しから返されたオブジェクトは、2番目のメソッドに引数として渡されますが、返された元のオブジェクトの値はに
null
なります。An object returned from a method call is then passed as an argument to a second method, but the value of the original returned object isnull
. このエラーを回避するには、戻り値がであることを確認null
し、戻り値がでない場合にのみ2番目のメソッドを呼び出しnull
ます。To prevent the error, check for a return value that isnull
and call the second method only if the return value is notnull
.
ArgumentNullException は、ArgumentException と同じように動作します。ArgumentNullException behaves identically to ArgumentException. これは、アプリケーションコードが、引数によって発生した例外 null
と null 以外の引数によって発生した例外を区別できるようにするために用意されています。It is provided so that application code can differentiate between exceptions caused by null
arguments and exceptions caused by arguments that are not null. null 以外の引数によるエラーについては、「ArgumentOutOfRangeException」を参照してください。For errors caused by arguments that are not null, see ArgumentOutOfRangeException.
ArgumentNullException では、0x80004003 値を持つ HRESULT E_POINTER が使用されます。ArgumentNullException uses the HRESULT E_POINTER, which has the value 0x80004003.
インスタンスの初期プロパティ値の一覧についてはArgumentNullExceptionを参照してください、ArgumentNullExceptionコンス トラクター。For a list of initial property values for an instance of ArgumentNullException, see the ArgumentNullException constructors.
コンストラクター
ArgumentNullException() |
ArgumentNullException クラスの新しいインスタンスを初期化します。Initializes a new instance of the ArgumentNullException class. |
ArgumentNullException(SerializationInfo, StreamingContext) |
シリアル化したデータを使用して、ArgumentNullException クラスの新しいインスタンスを初期化します。Initializes a new instance of the ArgumentNullException class with serialized data. |
ArgumentNullException(String) |
この例外の原因である引数の名前を指定して、ArgumentNullException クラスの新しいインスタンスを初期化します。Initializes a new instance of the ArgumentNullException class with the name of the parameter that causes this exception. |
ArgumentNullException(String, Exception) |
エラー メッセージ、およびこの例外の原因である例外を指定して、ArgumentNullException クラスの新しいインスタンスを初期化します。Initializes a new instance of the ArgumentNullException class with a specified error message and the exception that is the cause of this exception. |
ArgumentNullException(String, String) |
指定したエラー メッセージと、この例外の原因である引数の名前を使用して、ArgumentNullException クラスのインスタンスを初期化します。Initializes an instance of the ArgumentNullException class with a specified error message and the name of the parameter that causes this exception. |
プロパティ
Data |
例外に関する追加のユーザー定義情報を提供する、キーと値のペアのコレクションを取得します。Gets a collection of key/value pairs that provide additional user-defined information about the exception. (継承元 Exception) |
HelpLink |
この例外に関連付けられているヘルプ ファイルへのリンクを取得または設定します。Gets or sets a link to the help file associated with this exception. (継承元 Exception) |
HResult |
特定の例外に割り当てられているコード化数値である HRESULT を取得または設定します。Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (継承元 Exception) |
InnerException |
現在の例外の原因となる Exception インスタンスを取得します。Gets the Exception instance that caused the current exception. (継承元 Exception) |
Message |
エラー メッセージとパラメーター名を取得します。パラメーター名が設定されていない場合は、エラー メッセージだけを取得します。Gets the error message and the parameter name, or only the error message if no parameter name is set. (継承元 ArgumentException) |
ParamName |
この例外の原因である引数の名前を取得します。Gets the name of the parameter that causes this exception. (継承元 ArgumentException) |
Source |
エラーの原因となるアプリケーションまたはオブジェクトの名前を取得または設定します。Gets or sets the name of the application or the object that causes the error. (継承元 Exception) |
StackTrace |
呼び出し履歴で直前のフレームの文字列形式を取得します。Gets a string representation of the immediate frames on the call stack. (継承元 Exception) |
TargetSite |
現在の例外がスローされたメソッドを取得します。Gets the method that throws the current exception. (継承元 Exception) |
メソッド
Equals(Object) |
指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified object is equal to the current object. (継承元 Object) |
GetBaseException() |
派生クラスでオーバーライドされた場合、それ以後に発生する 1 つ以上の例外の根本原因である Exception を返します。When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (継承元 Exception) |
GetHashCode() |
既定のハッシュ関数として機能します。Serves as the default hash function. (継承元 Object) |
GetObjectData(SerializationInfo, StreamingContext) |
パラメーター名と追加の例外情報を使用して SerializationInfo オブジェクトを設定します。Sets the SerializationInfo object with the parameter name and additional exception information. (継承元 ArgumentException) |
GetType() |
現在のインスタンスのランタイム型を取得します。Gets the runtime type of the current instance. (継承元 Exception) |
MemberwiseClone() |
現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object. (継承元 Object) |
ToString() |
現在の例外の文字列形式を作成して返します。Creates and returns a string representation of the current exception. (継承元 Exception) |
イベント
SerializeObjectState |
例外がシリアル化され、例外に関するシリアル化されたデータを含む例外状態オブジェクトが作成されたときに発生します。Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception. (継承元 Exception) |