Skip to content

Commit

Permalink
picturebox breaking change (#41695)
Browse files Browse the repository at this point in the history
  • Loading branch information
gewarren authored Jul 11, 2024
1 parent 2664e9f commit c8e212a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/core/compatibility/9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff
| [ComponentDesigner.Initialize throws ArgumentNullException](windows-forms/9.0/componentdesigner-initialize.md) | Behavioral change | Preview 1 |
| [DataGridViewRowAccessibleObject.Name starting row index](windows-forms/9.0/datagridviewrowaccessibleobject-name-row.md) | Behavioral change | Preview 1 |
| [No exception if DataGridView is null](windows-forms/9.0/datagridviewheadercell-nre.md) | Behavioral change | Preview 1 |
| [PictureBox raises HttpClient exceptions](windows-forms/9.0/httpclient-exceptions.md) | Behavioral change | Preview 6 |

## WPF

Expand Down
4 changes: 4 additions & 0 deletions docs/core/compatibility/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ items:
href: windows-forms/9.0/datagridviewrowaccessibleobject-name-row.md
- name: No exception if DataGridView is null
href: windows-forms/9.0/datagridviewheadercell-nre.md
- name: PictureBox raises HttpClient exceptions
href: windows-forms/9.0/httpclient-exceptions.md
- name: WPF
items:
- name: "'GetXmlNamespaceMaps' type change"
Expand Down Expand Up @@ -1832,6 +1834,8 @@ items:
href: windows-forms/9.0/datagridviewrowaccessibleobject-name-row.md
- name: No exception if DataGridView is null
href: windows-forms/9.0/datagridviewheadercell-nre.md
- name: PictureBox raises HttpClient exceptions
href: windows-forms/9.0/httpclient-exceptions.md
- name: .NET 8
items:
- name: Anchor layout changes
Expand Down
36 changes: 36 additions & 0 deletions docs/core/compatibility/windows-forms/9.0/httpclient-exceptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: "Breaking change: PictureBox raises HttpClient exceptions"
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.
ms.date: 07/09/2024
---
# PictureBox raises HttpClient exceptions

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>.

## Version introduced

.NET 9 Preview 6

## Previous behavior

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.

## New behavior

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.

## Change category

This change is a [*behavioral change*](../../categories.md#behavioral-change).

## Reason for change

<xref:System.Net.WebClient> is obsolete.

## Recommended action

Update your code to catch <xref:System.Net.Http.HttpRequestException> and <xref:System.Threading.Tasks.TaskCanceledException> instead of <xref:System.Net.WebException>.

## Affected APIs

- <xref:System.Windows.Forms.PictureBox> control

0 comments on commit c8e212a

Please sign in to comment.