WinForms メソッドで ArgumentNullException がスローされるようになった
一部の Windows フォーム メソッドで、null 引数について ArgumentNullException がスローされるようになりました。以前は NullReferenceException がスローされていました。
変更の説明
以前は、null の引数が渡された場合、特定の Windows フォーム メソッドでは NullReferenceException がスローされていました。 .NET 5 以降、これらのメソッドでは、null 引数に対して ArgumentNullException が代わりにスローされるようになりました。
ArgumentNullException をスローすることは、.NET ランタイムの動作に準拠しています。 また、引数が null であることと、どの引数がそうであるのかが明確に伝えられることで、デバッグ エクスペリエンスが向上します。
導入されたバージョン
.NET 5.0
推奨アクション
これらのメソッドのいずれかを呼び出す場合、コードでは現在 null 引数について NullReferenceException をキャッチする場合は、代わりに ArgumentNullException をキャッチします。 さらに、リストされているメソッドに null 引数が渡されないようにコードを更新することを検討してください。
影響を受ける API
次の表では、影響を受けるメソッドとパラメーターを示します。
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET