From 970d5ed6953df1ab52be1121800212ca4517ee02 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 Aug 2025 21:20:51 +0000 Subject: [PATCH 1/6] Initial plan From bbdd2a8f448ae8551ac69266525bd34ee9e085b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 Aug 2025 21:30:03 +0000 Subject: [PATCH 2/6] Add System.Drawing OutOfMemoryException breaking change documentation for .NET 10 Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com> --- docs/core/compatibility/10.0.md | 1 + ...m-drawing-outofmemory-externalexception.md | 61 +++++++++++++++++++ docs/core/compatibility/toc.yml | 2 + 3 files changed, 64 insertions(+) create mode 100644 docs/core/compatibility/core-libraries/10.0/system-drawing-outofmemory-externalexception.md diff --git a/docs/core/compatibility/10.0.md b/docs/core/compatibility/10.0.md index 1e880ac7f620e..d063b6af68e47 100644 --- a/docs/core/compatibility/10.0.md +++ b/docs/core/compatibility/10.0.md @@ -44,6 +44,7 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af | [DriveInfo.DriveFormat returns Linux filesystem types](core-libraries/10.0/driveinfo-driveformat-linux.md) | Behavioral change | Preview 6 | | [DynamicallyAccessedMembers annotation removed from DefaultValueAttribute ctor](core-libraries/10.0/defaultvalueattribute-dynamically-accessed-members.md) | Binary/source incompatible | Preview 7 | | [GnuTarEntry and PaxTarEntry no longer includes atime and ctime by default](core-libraries/10.0/tar-atime-ctime-default.md) | Behavioral change | Preview 5 | +| [System.Drawing OutOfMemoryException changed to ExternalException](core-libraries/10.0/system-drawing-outofmemory-externalexception.md) | Behavioral change | Preview 5 | | [LDAP DirectoryControl parsing is now more stringent](core-libraries/10.0/ldap-directorycontrol-parsing.md) | Behavioral change | Preview 1 | | [MacCatalyst version normalization](core-libraries/10.0/maccatalyst-version-normalization.md) | Behavioral change | Preview 1 | | [.NET runtime no longer provides default SIGTERM signal handler](core-libraries/10.0/sigterm-signal-handler.md) | Behavioral change | Preview 5 | diff --git a/docs/core/compatibility/core-libraries/10.0/system-drawing-outofmemory-externalexception.md b/docs/core/compatibility/core-libraries/10.0/system-drawing-outofmemory-externalexception.md new file mode 100644 index 0000000000000..6fc0f55243431 --- /dev/null +++ b/docs/core/compatibility/core-libraries/10.0/system-drawing-outofmemory-externalexception.md @@ -0,0 +1,61 @@ +--- +title: "Breaking change: System.Drawing OutOfMemoryException changed to ExternalException" +description: "Learn about the breaking change in .NET 10 where System.Drawing GDI+ OutOfMemory errors now throw ExternalException instead of OutOfMemoryException." +ms.date: 08/15/2025 +ai-usage: ai-assisted +--- + +# System.Drawing OutOfMemoryException changed to ExternalException + +GDI+ error handling in System.Drawing has been updated to throw instead of for `Status.OutOfMemory` errors. + +## Version introduced + +.NET 10 Preview 5 + +## Previous behavior + +When GDI+ encountered `Status.OutOfMemory` errors (often due to invalid input rather than actual memory issues), System.Drawing APIs threw . + +## New behavior + +When GDI+ encounters `Status.OutOfMemory` errors, System.Drawing APIs now throw instead. + +## Type of breaking change + +This is a [behavioral change](../../categories.md#behavioral-change). + +## Reason for change + +GDI+ isn't particularly good at returning errors when it's unable to create internal objects. There are many cases where object creation fails due to invalid input, and higher-level code gets a null and turns it into `Status.OutOfMemory`. This is frequently a source of confusion since the error is often not related to actual memory issues. + +The change to `ExternalException` provides more accurate error reporting, as this exception type is already thrown in other System.Drawing code paths for similar GDI+ errors. + +## Recommended action + +If your code catches `OutOfMemoryException` when using System.Drawing APIs, ensure you also catch `ExternalException` to handle these GDI+ errors. + +```csharp +try +{ + // System.Drawing operations +} +catch (ExternalException ex) +{ + // Handle GDI+ errors (including former OutOfMemoryException cases) +} +catch (OutOfMemoryException ex) +{ + // Handle actual memory issues +} +``` + +## Affected APIs + +All System.Drawing APIs that interact with GDI+ and previously could throw `OutOfMemoryException` for `Status.OutOfMemory` errors, including but not limited to: + +- constructors and methods +- methods +- methods +- constructors and methods +- Other System.Drawing types that use GDI+ internally diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index 17681c3d90a0b..47b441f8158a6 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -54,6 +54,8 @@ items: href: core-libraries/10.0/sigterm-signal-handler.md - name: System.Linq.AsyncEnumerable included in core libraries href: core-libraries/10.0/asyncenumerable.md + - name: System.Drawing OutOfMemoryException changed to ExternalException + href: core-libraries/10.0/system-drawing-outofmemory-externalexception.md - name: YMM embedded rounding removed from AVX10.2 href: core-libraries/10.0/ymm-embedded-rounding.md - name: Cryptography From ca13bcf5387aaac7558404c3c6f66d1c503cd198 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 Aug 2025 18:19:25 +0000 Subject: [PATCH 3/6] Move System.Drawing breaking change from core-libraries to windows-forms Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com> --- docs/core/compatibility/10.0.md | 2 +- docs/core/compatibility/toc.yml | 4 ++-- .../10.0/system-drawing-outofmemory-externalexception.md | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename docs/core/compatibility/{core-libraries => windows-forms}/10.0/system-drawing-outofmemory-externalexception.md (100%) diff --git a/docs/core/compatibility/10.0.md b/docs/core/compatibility/10.0.md index d063b6af68e47..2b6f0d9fde023 100644 --- a/docs/core/compatibility/10.0.md +++ b/docs/core/compatibility/10.0.md @@ -44,7 +44,6 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af | [DriveInfo.DriveFormat returns Linux filesystem types](core-libraries/10.0/driveinfo-driveformat-linux.md) | Behavioral change | Preview 6 | | [DynamicallyAccessedMembers annotation removed from DefaultValueAttribute ctor](core-libraries/10.0/defaultvalueattribute-dynamically-accessed-members.md) | Binary/source incompatible | Preview 7 | | [GnuTarEntry and PaxTarEntry no longer includes atime and ctime by default](core-libraries/10.0/tar-atime-ctime-default.md) | Behavioral change | Preview 5 | -| [System.Drawing OutOfMemoryException changed to ExternalException](core-libraries/10.0/system-drawing-outofmemory-externalexception.md) | Behavioral change | Preview 5 | | [LDAP DirectoryControl parsing is now more stringent](core-libraries/10.0/ldap-directorycontrol-parsing.md) | Behavioral change | Preview 1 | | [MacCatalyst version normalization](core-libraries/10.0/maccatalyst-version-normalization.md) | Behavioral change | Preview 1 | | [.NET runtime no longer provides default SIGTERM signal handler](core-libraries/10.0/sigterm-signal-handler.md) | Behavioral change | Preview 5 | @@ -122,6 +121,7 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af | [Renamed parameter in HtmlElement.InsertAdjacentElement](windows-forms/10.0/insertadjacentelement-orientation.md) | Source incompatible | Preview 1 | | [TreeView checkbox image truncation](windows-forms/10.0/treeview-text-location.md) | Behavioral change | Preview 1 | | [StatusStrip uses System RenderMode by default](windows-forms/10.0/statusstrip-renderer.md) | Behavioral change | Preview 1 | +| [System.Drawing OutOfMemoryException changed to ExternalException](windows-forms/10.0/system-drawing-outofmemory-externalexception.md) | Behavioral change | Preview 5 | ## Windows Presentation Foundation (WPF) diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index 47b441f8158a6..399f012307a0e 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -54,8 +54,6 @@ items: href: core-libraries/10.0/sigterm-signal-handler.md - name: System.Linq.AsyncEnumerable included in core libraries href: core-libraries/10.0/asyncenumerable.md - - name: System.Drawing OutOfMemoryException changed to ExternalException - href: core-libraries/10.0/system-drawing-outofmemory-externalexception.md - name: YMM embedded rounding removed from AVX10.2 href: core-libraries/10.0/ymm-embedded-rounding.md - name: Cryptography @@ -138,6 +136,8 @@ items: href: windows-forms/10.0/treeview-text-location.md - name: StatusStrip uses System RenderMode by default href: windows-forms/10.0/statusstrip-renderer.md + - name: System.Drawing OutOfMemoryException changed to ExternalException + href: windows-forms/10.0/system-drawing-outofmemory-externalexception.md - name: WPF items: - name: Incorrect usage of DynamicResource causes application crash diff --git a/docs/core/compatibility/core-libraries/10.0/system-drawing-outofmemory-externalexception.md b/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md similarity index 100% rename from docs/core/compatibility/core-libraries/10.0/system-drawing-outofmemory-externalexception.md rename to docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md From 24cf26fef0c0fbaa363424698074de67df1f5bd8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 Aug 2025 19:55:22 +0000 Subject: [PATCH 4/6] Add VB.NET example and language metadata for System.Drawing breaking change Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com> --- ...m-drawing-outofmemory-externalexception.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md b/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md index 6fc0f55243431..2d88a004b679c 100644 --- a/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md +++ b/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md @@ -3,6 +3,9 @@ title: "Breaking change: System.Drawing OutOfMemoryException changed to External description: "Learn about the breaking change in .NET 10 where System.Drawing GDI+ OutOfMemory errors now throw ExternalException instead of OutOfMemoryException." ms.date: 08/15/2025 ai-usage: ai-assisted +dev_langs: +- CSharp +- VB --- # System.Drawing OutOfMemoryException changed to ExternalException @@ -35,6 +38,8 @@ The change to `ExternalException` provides more accurate error reporting, as thi If your code catches `OutOfMemoryException` when using System.Drawing APIs, ensure you also catch `ExternalException` to handle these GDI+ errors. +### [C#](#tab/csharp) + ```csharp try { @@ -50,6 +55,20 @@ catch (OutOfMemoryException ex) } ``` +### [VB.NET](#tab/vb) + +```vb +Try + ' System.Drawing operations +Catch ex As ExternalException + ' Handle GDI+ errors (including former OutOfMemoryException cases) +Catch ex As OutOfMemoryException + ' Handle actual memory issues +End Try +``` + +--- + ## Affected APIs All System.Drawing APIs that interact with GDI+ and previously could throw `OutOfMemoryException` for `Status.OutOfMemory` errors, including but not limited to: From 1a6989c98f60e3fc600a1235a95bad8d2d7f250f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 Aug 2025 20:10:09 +0000 Subject: [PATCH 5/6] Remove tab structure from code examples, let metadata handle rendering Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com> --- .../10.0/system-drawing-outofmemory-externalexception.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md b/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md index 2d88a004b679c..6409581cfff56 100644 --- a/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md +++ b/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md @@ -38,8 +38,6 @@ The change to `ExternalException` provides more accurate error reporting, as thi If your code catches `OutOfMemoryException` when using System.Drawing APIs, ensure you also catch `ExternalException` to handle these GDI+ errors. -### [C#](#tab/csharp) - ```csharp try { @@ -55,8 +53,6 @@ catch (OutOfMemoryException ex) } ``` -### [VB.NET](#tab/vb) - ```vb Try ' System.Drawing operations @@ -67,8 +63,6 @@ Catch ex As OutOfMemoryException End Try ``` ---- - ## Affected APIs All System.Drawing APIs that interact with GDI+ and previously could throw `OutOfMemoryException` for `Status.OutOfMemory` errors, including but not limited to: From 4fbf2ed106d2ba8f5d933331688697424f8db921 Mon Sep 17 00:00:00 2001 From: "Andy (Steve) De George" <67293991+adegeo@users.noreply.github.com> Date: Tue, 19 Aug 2025 07:34:45 -0700 Subject: [PATCH 6/6] Update docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- .../10.0/system-drawing-outofmemory-externalexception.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md b/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md index 6409581cfff56..8c1049f6bee74 100644 --- a/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md +++ b/docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md @@ -22,7 +22,7 @@ When GDI+ encountered `Status.OutOfMemory` errors (often due to invalid input ra ## New behavior -When GDI+ encounters `Status.OutOfMemory` errors, System.Drawing APIs now throw instead. +Starting in .NET 10, when GDI+ encounters `Status.OutOfMemory` errors, System.Drawing APIs now throw . ## Type of breaking change