Skip to content

Document System.Drawing OutOfMemoryException to ExternalException breaking change for .NET 10 with C# and VB examples #47939

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

Merged
merged 6 commits into from
Aug 19, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 12, 2025

This PR adds documentation for a breaking change in .NET 10 Preview 5 where System.Drawing's GDI+ error handling was updated to throw ExternalException instead of OutOfMemoryException for Status.OutOfMemory errors.

Changes Made

Added new breaking change document: docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md

  • Documents the version introduced (.NET 10 Preview 5)
  • Explains previous vs new behavior with GDI+ error handling
  • Provides reasoning: GDI+ often returns Status.OutOfMemory for invalid input rather than actual memory issues, causing confusion
  • Includes recommended action with code examples in both C# and VB.NET showing how to catch both exception types using tab groups
  • Lists affected System.Drawing APIs that use GDI+ internally
  • Updated metadata to specify both C# and VB languages are covered

Updated main compatibility index: docs/core/compatibility/10.0.md

  • Added entry to Windows Forms table in correct alphabetical order

Updated table of contents: docs/core/compatibility/toc.yml

  • Added navigation entry under Windows Forms section

Background

GDI+ isn't particularly good at returning errors when it's unable to create internal objects. Many cases where object creation fails due to invalid input result in higher-level code getting a null and turning it into Status.OutOfMemory. This change to ExternalException provides more accurate error reporting since this exception type is already used in other System.Drawing code paths for similar GDI+ errors.

The documentation follows established patterns and includes proper cross-references, code examples in both languages, and comprehensive coverage of affected APIs.

Fixes #46057.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


Internal previews

📄 File 🔗 Preview link
docs/core/compatibility/10.0.md Breaking changes in .NET 10
docs/core/compatibility/toc.yml docs/core/compatibility/toc
docs/core/compatibility/windows-forms/10.0/system-drawing-outofmemory-externalexception.md System.Drawing OutOfMemoryException changed to ExternalException

… for .NET 10

Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] [Breaking change]: System.Drawing OutOfMemoryException changed to ExternalException Document System.Drawing OutOfMemoryException to ExternalException breaking change for .NET 10 Aug 12, 2025
Copilot finished work on behalf of adegeo August 12, 2025 21:33
@Copilot Copilot AI requested a review from adegeo August 12, 2025 21:33
Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
Copy link
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 issues. Other issues are also a high priority. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

Copilot finished work on behalf of adegeo August 14, 2025 18:20
@adegeo adegeo requested a review from gewarren August 14, 2025 19:40
…change

Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
Copy link
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 issues. Other issues are also a high priority. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@Copilot Copilot AI changed the title Document System.Drawing OutOfMemoryException to ExternalException breaking change for .NET 10 Document System.Drawing OutOfMemoryException to ExternalException breaking change for .NET 10 with C# and VB examples Aug 14, 2025
@Copilot Copilot AI requested a review from adegeo August 14, 2025 19:56
Copilot finished work on behalf of adegeo August 14, 2025 19:56
Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
@Copilot Copilot AI requested a review from adegeo August 14, 2025 20:11
Copilot finished work on behalf of adegeo August 14, 2025 20:11
Copy link
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 issues. Other issues are also a high priority. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@adegeo
Copy link
Contributor

adegeo commented Aug 14, 2025

@gewarren This is ready

@adegeo adegeo marked this pull request as ready for review August 14, 2025 20:20
@adegeo adegeo requested a review from a team as a code owner August 14, 2025 20:20
…fmemory-externalexception.md

Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
@adegeo adegeo enabled auto-merge (squash) August 19, 2025 14:35
@adegeo adegeo merged commit 6954c15 into main Aug 19, 2025
10 checks passed
@adegeo adegeo deleted the copilot/fix-46057 branch August 19, 2025 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Breaking change]: System.Drawing OutOfMemoryException changed to ExternalException
3 participants