다음을 통해 공유


WinForms 메서드가 이제 ArgumentNullException을 throw합니다.

일부 Windows Forms 메서드는 이제 null 인수에 대해 ArgumentNullException을(를) throw합니다. 이전에는 NullReferenceException을(를) throw했습니다.

변경 내용 설명

이전에는 특정 Windows Forms 메서드가 null인 인수가 전달되면 NullReferenceException 예외를 발생시켰습니다. .NET 5부터 이러한 메서드는 이제 null 인수를 대신 throw ArgumentNullException 합니다.

ArgumentNullException 예외를 던지는 것은 .NET 런타임의 동작을 따릅니다. 또한 인수가 null이고 어떤 인수인지 명확하게 전달하여 디버깅 환경을 개선합니다.

도입된 버전

.NET 5.0

이러한 메서드를 호출할 때 코드가 현재 null 인수를 NullReferenceException으로 catch하고 있다면, 대신 ArgumentNullException으로 catch하십시오. 또한 나열된 메서드에 null 인수를 전달하지 않도록 코드를 업데이트하는 것이 좋습니다.

영향을 받는 API

다음 표에서는 영향을 받는 메서드 및 매개 변수를 나열합니다.

메서드 매개 변수 이름 추가된 버전
Control.ControlCollection(Control) owner 미리 보기 1
TabControl.GetToolTipText(Object) item 미리 보기 1
TableLayoutControlCollection(TableLayoutPanel) container 미리 보기 1
ToolStripRenderer.OnRenderArrow(ToolStripArrowRenderEventArgs) e 미리 보기 1
ToolStripRenderer.OnRenderItemCheck(ToolStripItemImageRenderEventArgs) e 미리 보기 1
ToolStripRenderer.OnRenderItemImage(ToolStripItemImageRenderEventArgs) e 미리 보기 1
ToolStripRenderer.OnRenderItemText(ToolStripItemTextRenderEventArgs) e 미리 보기 1
ToolStripRenderer.OnRenderStatusStripSizingGrip(ToolStripRenderEventArgs) > e 미리 보기 1
DataGridViewComboBoxEditingControl.ApplyCellStyleToEditingControl(DataGridViewCellStyle) dataGridViewCellStyle 미리 보기 2
RichTextBox.LoadFile(Stream, RichTextBoxStreamType) data 미리 보기 2
ListBox.IntegerCollection(ListBox) owner 미리 보기 5
ListBox.IntegerCollection.CopyTo(Array, Int32) destination 미리 보기 5
ListViewGroup.ISerializable.GetObjectData(SerializationInfo, StreamingContext) info 미리 보기 5
VisualStyleRenderer(String, Int32, Int32) className 미리 보기 5
ListBox.ObjectCollection(ListBox) owner 미리 보기 6
ListBox.ObjectCollection(ListBox, Object[]) owner, value 미리 보기 6
ListBox.ObjectCollection(ListBox, ListBox+ObjectCollection) owner, value 미리 보기 6
ListBox.ObjectCollection.AddRange(Object[]) items 미리 보기 6
ListBox.ObjectCollection.AddRange(ListBox+ObjectCollection) value 미리 보기 6
ListBox.ObjectCollection.CopyTo(Object[], Int32) destination 미리 보기 6
ListBox.ObjectCollection.ICollection.CopyTo(Array, Int32) destination 미리 보기 6
ListView.SelectedIndexCollection(ListView) owner 미리 보기 7
TreeNodeCollection.Find(String, Boolean) keynull이거나 비어 있음 미리 보기 8
ListView.ListViewItemCollection.Find(String, Boolean) keynull이거나 비어 있음 RC1
ScrollableControl.OnPaintBackground(PaintEventArgs) e RC1