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

System.Drawing.Common tests failed on Windows Mono due to COM wrappers #55655

Closed
akoeplinger opened this issue Jul 14, 2021 · 13 comments
Closed

Comments

@akoeplinger
Copy link
Member

akoeplinger commented Jul 14, 2021

After #54884 these tests started failing on Mono on Windows:

  • ToBitmap_PngIconSupportedInSwitches_Success
  • ToBitmap_PngIconNotSupportedInSwitches_ThrowsArgumentOutOfRangeException
  • Ctor_IntPtrZeroIV_ThrowsArgumentException
  • Ctor_InvalidFrameUnitIII_ThrowsArgumentException
  • Ctor_InvalidEmfTypeIII_ThrowsArgumentException

Probably something to do with Mono not supporting COM on Windows: #39704 (comment)

Example stacktrace:

  System.TypeInitializationException: The type initializer for 'System.Drawing.DrawingCom' threw an exception.
 ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
   at System.Drawing.DrawingCom.InitializeComInterfaceEntry() in /_/src/libraries/System.Drawing.Common/src/System/Drawing/DrawingCom.COMWrappers.cs:line 30
   at System.Drawing.DrawingCom..cctor() in /_/src/libraries/System.Drawing.Common/src/System/Drawing/DrawingCom.COMWrappers.cs:line 22
   --- End of inner exception stack trace ---
   at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) in /_/src/libraries/System.Drawing.Common/src/System/Drawing/Image.Windows.cs:line 248
   at System.Drawing.Image.Save(Stream stream, ImageFormat format) in /_/src/libraries/System.Drawing.Common/src/System/Drawing/Image.Windows.cs:line 210
   at System.Drawing.Tests.IconTests.GetPngIcon() in /_/src/libraries/System.Drawing.Common/tests/IconTests.cs:line 685
   at System.Drawing.Tests.IconTests.<ToBitmap_PngIconSupportedInSwitches_Success>g__VerifyPng|44_0() in /_/src/libraries/System.Drawing.Common/tests/IconTests.cs:line 618
   at System.Drawing.Tests.IconTests.<>c.<ToBitmap_PngIconSupportedInSwitches_Success>b__44_1() in /_/src/libraries/System.Drawing.Common/tests/IconTests.cs:line 640
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /_/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs:line 370
@akoeplinger akoeplinger added this to the 7.0.0 milestone Jul 14, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jul 14, 2021
@ghost
Copy link

ghost commented Jul 14, 2021

Tagging subscribers to this area:
See info in area-owners.md if you want to be subscribed.

Issue Details

After #54884 these tests started failing on Mono on Windows:

  • ToBitmap_PngIconSupportedInSwitches_Success
  • ToBitmap_PngIconNotSupportedInSwitches_ThrowsArgumentOutOfRangeException
  • Ctor_IntPtrZeroIV_ThrowsArgumentException
  • Ctor_InvalidFrameUnitIII_ThrowsArgumentException
  • Ctor_InvalidEmfTypeIII_ThrowsArgumentException

Example stacktrace:

  System.TypeInitializationException: The type initializer for 'System.Drawing.DrawingCom' threw an exception.
 ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
   at System.Drawing.DrawingCom.InitializeComInterfaceEntry() in /_/src/libraries/System.Drawing.Common/src/System/Drawing/DrawingCom.COMWrappers.cs:line 30
   at System.Drawing.DrawingCom..cctor() in /_/src/libraries/System.Drawing.Common/src/System/Drawing/DrawingCom.COMWrappers.cs:line 22
   --- End of inner exception stack trace ---
   at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) in /_/src/libraries/System.Drawing.Common/src/System/Drawing/Image.Windows.cs:line 248
   at System.Drawing.Image.Save(Stream stream, ImageFormat format) in /_/src/libraries/System.Drawing.Common/src/System/Drawing/Image.Windows.cs:line 210
   at System.Drawing.Tests.IconTests.GetPngIcon() in /_/src/libraries/System.Drawing.Common/tests/IconTests.cs:line 685
   at System.Drawing.Tests.IconTests.<ToBitmap_PngIconSupportedInSwitches_Success>g__VerifyPng|44_0() in /_/src/libraries/System.Drawing.Common/tests/IconTests.cs:line 618
   at System.Drawing.Tests.IconTests.<>c.<ToBitmap_PngIconSupportedInSwitches_Success>b__44_1() in /_/src/libraries/System.Drawing.Common/tests/IconTests.cs:line 640
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /_/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs:line 370

Probably something to do with not supporting COM on Mono on Windows: #39704 (comment)

Author: akoeplinger
Assignees: -
Labels:

area-VM-meta-mono, os-windows

Milestone: 7.0.0

@akoeplinger akoeplinger removed the untriaged New issue has not been triaged by the area owner label Jul 14, 2021
akoeplinger added a commit to akoeplinger/runtime that referenced this issue Jul 14, 2021
After dotnet#54884 these tests started failing on Mono on Windows, see dotnet#55655.
akoeplinger added a commit that referenced this issue Jul 14, 2021
)

After #54884 these tests started failing on Mono on Windows, see #55655.
@danmoseley
Copy link
Member

@safern do we support System.Drawing on Mono Windows at all? I assume not -- the whole test library should not run in that config.

@safern
Copy link
Member

safern commented Jul 14, 2021

That's a good question, but actually we do 😄

@danmoseley
Copy link
Member

Ah I see, we only use COM for a few things - Bitmaps, Images, Metafiles? In that case, unless we think the message is bad, this issue can be closed as by design.

@safern
Copy link
Member

safern commented Jul 14, 2021

This was caused because we needed to use COMWrappers on 6.0 to make it trimmable safe. However it seems like Mono doesn't support COMWrappers? And yeah, the COMWrappers are mostly used to read Images from streams as we need to use an IStream com interface because that is what GDI+ uses.

Perhaps we could condition the code to use the legacy COM if running on Mono?

cc: @eerhardt

@eerhardt
Copy link
Member

I was under the impression that Mono didn't support COM at all.

Perhaps we could condition the code to use the legacy COM if running on Mono?

Is that worth it? What are the scenarios where customers will run with Mono on Windows?

COMWrappers are the way forward. If we believe "Mono on Windows" is important, then Mono needs to support COMWrappers. We are going to be converting more and more COM usage over to COMWrappers, so this will just crop up in more places.

cc @jkotas @AaronRobinsonMSFT

@jkotas
Copy link
Member

jkotas commented Jul 15, 2021

We do not have official support for Mono on Windows.

@akoeplinger
Copy link
Member Author

/cc @marek-safar @lambdageek @lateralusX what would it take to enable COM Wrapper support on mono?

@marek-safar marek-safar modified the milestones: 7.0.0, Future Jul 15, 2021
@marek-safar
Copy link
Contributor

It's not in our plans so this we should just disable the tests if it's blocking anyone

@lambdageek
Copy link
Member

I was under the impression that Mono didn't support COM at all.

There is support for the legacy COM interop in Mono on Windows and Linux, but yea Mono on Windows is not supported in .net 6.

COMWrappers are the way forward. If we believe "Mono on Windows" is important, then Mono needs to support COMWrappers. We are going to be converting more and more COM usage over to COMWrappers, so this will just crop up in more places.

Agreed.

what would it take to enable COM Wrapper support on mono?

A bunch of work. I made a new issue to keep track #55742

@IS4Code
Copy link

IS4Code commented Aug 23, 2021

I started getting a similar issue after trying 6.0 preview, on Windows 7, where I am fairly sure GDI+ is supported. Is it related to this issue?

System.PlatformNotSupportedException: System.Drawing.Common is not supported on this platform.
   at System.Drawing.Drawing2D.Matrix..ctor(Single m11, Single m12, Single m21, Single m22, Single dx, Single dy)

Works fine in older versions.

@akoeplinger
Copy link
Member Author

@IllidanS4 no that's unrelated, I'd suggest filing a separate issue.

ViktorHofer pushed a commit to dotnet/winforms that referenced this issue Dec 5, 2022
@JeremyKuhne
Copy link
Member

System.Drawing.Common has moved to WinForms.

@ghost ghost locked as resolved and limited conversation to collaborators May 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants