Skip to content

[release/10.0.1xx] Add System.Private.Windows.GdiPlus to WPF#3120

Merged
ericstj merged 1 commit intorelease/10.0.1xxfrom
ericstj-GdiPlus-wpf
Oct 29, 2025
Merged

[release/10.0.1xx] Add System.Private.Windows.GdiPlus to WPF#3120
ericstj merged 1 commit intorelease/10.0.1xxfrom
ericstj-GdiPlus-wpf

Conversation

@ericstj
Copy link
Member

@ericstj ericstj commented Oct 27, 2025

Customer Impact

  • Customer reported
  • Found internally

When applying a using statement or casting any of the following types to an interface in a WPF project, a compiler error is emitted: Bitmap, Image, MetaFile, Icon, Graphics.

using var bitmap = new Bitmap(100, 100);
error CS0012: The type 'IImage' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.Windows.GdiPlus, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Background

Due to dotnet/roslyn#80921 my fix #2839 for dotnet/sdk#51173 was incomplete. When any interface cast or using statement is applied to Bitmap or any other type that implements internal interfaces from System.Private.Windows.GdiPlus the compiler will fail with CS0012 error, even though it does not need to call those interfaces.

To workaround this, the reference can be added to the project, in the same way as before - see dotnet/sdk#51173 (comment)

We missed this in the first fix as we didn't test a user scenario involving a cast or a using statement on one of the impacted types. This fix does not omit any other private dependencies of System.Drawing.Common.

Regression

  • Yes
  • No

Regressed in .NET 10.0 when enabling pruning for WindowsDesktop shared framework, fix in GA was not complete.

Testing

Verified customer repro is fixed. Verified closure of System.Drawing.Common is exposed for reference -- no other assembly private or otherwise is omitted.

Risk

Low - this is essentially just extending the previous fix. The added assembly contains entirely internal API.

@ericstj ericstj added the Servicing-consider Issue for next servicing release review label Oct 27, 2025
@dotnet-policy-service dotnet-policy-service bot requested a review from a team October 27, 2025 22:22
@rbhanda rbhanda added this to the 10.0.1 milestone Oct 28, 2025
@ericstj ericstj added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Oct 29, 2025
@dotnet-policy-service dotnet-policy-service bot requested a review from a team October 29, 2025 00:26
@ericstj ericstj merged commit bbafab7 into release/10.0.1xx Oct 29, 2025
10 checks passed
@ericstj ericstj deleted the ericstj-GdiPlus-wpf branch October 29, 2025 00:27
@ericstj
Copy link
Member Author

ericstj commented Oct 29, 2025

This was approved over email and @mmitche let me know that release/10.0.1xx is open for approved fixes for 10.0.1 / 10.0.101.

@ericstj
Copy link
Member Author

ericstj commented Oct 29, 2025

/backport to main

@github-actions
Copy link
Contributor

Started backporting to main (link to workflow run)

@mmitche
Copy link
Member

mmitche commented Oct 29, 2025

This was approved over email and @mmitche let me know that release/10.0.1xx is open for approved fixes for 10.0.1 / 10.0.101.

Open now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Servicing-approved Approved for servicing release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants