WinForms methods now throw ArgumentNullException
Some Windows Forms methods now throw an ArgumentNullException for null arguments, where previously they threw a NullReferenceException.
Change description
Previously, certain Windows Forms methods threw a NullReferenceException if passed an argument that was null. Starting in .NET 5, these methods now throw an ArgumentNullException for null arguments, instead.
Throwing an ArgumentNullException conforms to the behavior of the .NET runtime. It also improves the debugging experience by clearly communicating that an argument is null and which argument it is.
Version introduced
.NET 5.0
Recommended action
If you call any of these methods and your code currently catches a NullReferenceException for null arguments, catch an ArgumentNullException instead. In addition, consider updating the code to prevent passing null arguments to the listed methods.
Affected APIs
The following table lists the affected methods and parameters: