Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Breaking change]: WinForms will raise HttpClient exceptions instead of WebClient in .NET 9 #41485

Closed
1 of 3 tasks
kasperk81 opened this issue Jun 19, 2024 · 0 comments · Fixed by #41695
Closed
1 of 3 tasks
Assignees
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 9 Work items for the .NET 9 release doc-idea Indicates issues that are suggestions for new topics [org][type][category] in-pr This issue will be closed (fixed) by an active pull request. Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest. source incompatible Source code may encounter a breaking change in behavior when targeting the new version.

Comments

@kasperk81
Copy link

kasperk81 commented Jun 19, 2024

Description

Instead of WebException from WebClient, it will raise HttpRequestException, TaskCanceledException etc. when network errors occur from PictureBox loading image from URL.

PR dotnet/winforms#11542

@lonitra

Version

.NET 9 Preview 6

Previous behavior

When PictureBox failed to load image from URL due to networking error, WebException is thrown: https://learn.microsoft.com/en-us/dotnet/api/system.net.webclient.openread#system-net-webclient-openread(system-string)

New behavior

When PictureBox failed to load image from URL due to networking error, HttpException or TaskCanceledException are thrown: https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.getstreamasync#system-net-http-httpclient-getstreamasync(system-uri-system-threading-cancellationtoken)

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code may require source changes to compile successfully.
  • Behavioral change: Existing binaries may behave differently at run time.

Reason for change

WebClient is being obsolete in .NET 9 runtime.

Recommended action

Following conditions are met:

  • System.Windows.Forms.PictureBox.UseWebRequest appcontext switch is true.
  • Picture is loaded from URL
  • User code is explicitly catching WebException, not its parent InvalidOperationException (which HttpClient also throws) or "catch all" block (catch { }, catch (Exception) { }).

Feature area

Windows Forms

Affected APIs

PictureBox control.


Associated WorkItem - 281895

@kasperk81 kasperk81 added breaking-change Indicates a .NET Core breaking change doc-idea Indicates issues that are suggestions for new topics [org][type][category] Pri1 High priority, do before Pri2 and Pri3 labels Jun 19, 2024
@dotnet-bot dotnet-bot added ⌚ Not Triaged Not triaged source incompatible Source code may encounter a breaking change in behavior when targeting the new version. labels Jun 19, 2024
@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Jun 20, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Jun 20, 2024
@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Jul 9, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Jul 9, 2024
@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Jul 9, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Jul 9, 2024
@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Jul 9, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Jul 9, 2024
@gewarren gewarren added the 🏁 Release: .NET 9 Work items for the .NET 9 release label Jul 9, 2024
@gewarren gewarren added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label Jul 9, 2024
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label Jul 9, 2024
@gewarren gewarren moved this from 🔖 Ready to 🏗 In progress in dotnet/docs July 2024 Sprint Jul 10, 2024
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Jul 10, 2024
@gewarren gewarren moved this from 🏗 In progress to 👀 In review in dotnet/docs July 2024 Sprint Jul 10, 2024
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in dotnet/docs July 2024 Sprint Jul 11, 2024
@dotnet-policy-service dotnet-policy-service bot added the in-pr This issue will be closed (fixed) by an active pull request. label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 9 Work items for the .NET 9 release doc-idea Indicates issues that are suggestions for new topics [org][type][category] in-pr This issue will be closed (fixed) by an active pull request. Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest. source incompatible Source code may encounter a breaking change in behavior when targeting the new version.
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants