Skip to content

Commit c8e212a

Browse files
authored
picturebox breaking change (dotnet#41695)
1 parent 2664e9f commit c8e212a

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

docs/core/compatibility/9.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff
5656
| [ComponentDesigner.Initialize throws ArgumentNullException](windows-forms/9.0/componentdesigner-initialize.md) | Behavioral change | Preview 1 |
5757
| [DataGridViewRowAccessibleObject.Name starting row index](windows-forms/9.0/datagridviewrowaccessibleobject-name-row.md) | Behavioral change | Preview 1 |
5858
| [No exception if DataGridView is null](windows-forms/9.0/datagridviewheadercell-nre.md) | Behavioral change | Preview 1 |
59+
| [PictureBox raises HttpClient exceptions](windows-forms/9.0/httpclient-exceptions.md) | Behavioral change | Preview 6 |
5960

6061
## WPF
6162

docs/core/compatibility/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ items:
5252
href: windows-forms/9.0/datagridviewrowaccessibleobject-name-row.md
5353
- name: No exception if DataGridView is null
5454
href: windows-forms/9.0/datagridviewheadercell-nre.md
55+
- name: PictureBox raises HttpClient exceptions
56+
href: windows-forms/9.0/httpclient-exceptions.md
5557
- name: WPF
5658
items:
5759
- name: "'GetXmlNamespaceMaps' type change"
@@ -1832,6 +1834,8 @@ items:
18321834
href: windows-forms/9.0/datagridviewrowaccessibleobject-name-row.md
18331835
- name: No exception if DataGridView is null
18341836
href: windows-forms/9.0/datagridviewheadercell-nre.md
1837+
- name: PictureBox raises HttpClient exceptions
1838+
href: windows-forms/9.0/httpclient-exceptions.md
18351839
- name: .NET 8
18361840
items:
18371841
- name: Anchor layout changes
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: "Breaking change: PictureBox raises HttpClient exceptions"
3+
description: Learn about the breaking change in .NET 9 for Windows Forms where `PictureBox` raises HttpClient exceptions for network errors when loading an image from a URL.
4+
ms.date: 07/09/2024
5+
---
6+
# PictureBox raises HttpClient exceptions
7+
8+
When <xref:System.Windows.Forms.PictureBox> loads an image from a URL and a network error occurs, it now raises <xref:System.Net.Http.HttpClient> exceptions, such as <xref:System.Net.Http.HttpRequestException> and <xref:System.Threading.Tasks.TaskCanceledException>, instead of <xref:System.Net.WebException>.
9+
10+
## Version introduced
11+
12+
.NET 9 Preview 6
13+
14+
## Previous behavior
15+
16+
Previously, when <xref:System.Windows.Forms.PictureBox> failed to load an image from a URL due to a network error, a <xref:System.Net.WebException> was thrown.
17+
18+
## New behavior
19+
20+
Starting in .NET 9, when <xref:System.Windows.Forms.PictureBox> fails to load an image from a URL due to a network error, <xref:System.Net.Http.HttpRequestException> or <xref:System.Threading.Tasks.TaskCanceledException> is thrown.
21+
22+
## Change category
23+
24+
This change is a [*behavioral change*](../../categories.md#behavioral-change).
25+
26+
## Reason for change
27+
28+
<xref:System.Net.WebClient> is obsolete.
29+
30+
## Recommended action
31+
32+
Update your code to catch <xref:System.Net.Http.HttpRequestException> and <xref:System.Threading.Tasks.TaskCanceledException> instead of <xref:System.Net.WebException>.
33+
34+
## Affected APIs
35+
36+
- <xref:System.Windows.Forms.PictureBox> control

0 commit comments

Comments
 (0)