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

[Linux] System.Drawing.Common not working on Linux #49275

Closed
djthegr8 opened this issue Mar 7, 2021 · 12 comments · Fixed by #49405
Closed

[Linux] System.Drawing.Common not working on Linux #49275

djthegr8 opened this issue Mar 7, 2021 · 12 comments · Fixed by #49405

Comments

@djthegr8
Copy link

djthegr8 commented Mar 7, 2021

Description

When using System.Drawing.Common, I am getting a DLL error with user32.dll as an import on Linux.

Configuration

  • Which version of .NET is the code running on? 5.0.2
  • What OS and version, and what distro if applicable? Ubuntu 20.04 Focal Fossa
  • What is the architecture (x64, x86, ARM, ARM64)? x64
  • Do you know whether it is specific to that configuration? No

Regression?

Not really, but it works in Windows

Other information

image

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Drawing untriaged New issue has not been triaged by the area owner labels Mar 7, 2021
@ghost
Copy link

ghost commented Mar 7, 2021

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

Issue Details

Description

When using System.Drawing.Common, I am getting a DLL error with user32.dll as an import on Linux.

Configuration

  • Which version of .NET is the code running on? 5.0.2
  • What OS and version, and what distro if applicable? Ubuntu 20.04 Focal Fossa
  • What is the architecture (x64, x86, ARM, ARM64)? x64
  • Do you know whether it is specific to that configuration? No

Regression?

Not really, but it works in Windows

Other information

image

Author: djthegr8
Assignees: -
Labels:

area-System.Drawing, untriaged

Milestone: -

@djthegr8 djthegr8 changed the title System.Drawing.Common not working on Linux [Linux] System.Drawing.Common not working on Linux Mar 7, 2021
@jkotas jkotas added the bug label Mar 7, 2021
@djthegr8
Copy link
Author

djthegr8 commented Mar 7, 2021

Update: It only happens for some specific data, and works otherwise

@safern
Copy link
Member

safern commented Mar 8, 2021

@djthegr8 thank you for the report. Would you mind sharing a simple repro so that I can test it out and see what is the issue?

@safern safern removed the untriaged New issue has not been triaged by the area owner label Mar 8, 2021
@safern safern added this to the 6.0.0 milestone Mar 8, 2021
@djthegr8
Copy link
Author

djthegr8 commented Mar 9, 2021

Because it is current a part of a modestly large project, it would take some time to reproduce, will try to send it as soon as possible

@ghost ghost added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed needs author feedback labels Mar 9, 2021
@jkotas
Copy link
Member

jkotas commented Mar 9, 2021

@safern The problem is pretty obvious by looking at the code. We have PInvokes of Windows GetSystemMetrics API in Unix binary. The problem is triggered when FillPie fails for some reason. You should be able to simulate it by changing FillPie to fail.

@safern safern removed the needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration label Mar 9, 2021
@safern
Copy link
Member

safern commented Mar 9, 2021

I see makes sense. It should fail with more than just FillPie. It seems like the call to GetSystemMetrics is trying to figure out if we are in a terminal server session that is remotely controlled. I think we can check if we are running on Windows before calling GetSystemMetrics.

@jkotas
Copy link
Member

jkotas commented Mar 9, 2021

System.Drawing.Common has separate builds for Windows vs. Unix, so it would be best to just not include the Windows PInvokes in the Unix builds.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 10, 2021
@djthegr8
Copy link
Author

Besides, could I get a better error because I don't know why FillPie should fail

@djthegr8
Copy link
Author

djthegr8 commented Mar 10, 2021

@safern correct me if I am wrong, but would the PR prevent this error and allow my code to run, or would it throw a different error?

@jkotas
Copy link
Member

jkotas commented Mar 10, 2021

@djthegr8 Yes, this change won't prevent the error. It will produce a better error message that should give you a better idea why FillPie is failing.

@djthegr8
Copy link
Author

djthegr8 commented Mar 10, 2021 via email

@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 11, 2021
@djthegr8
Copy link
Author

@safern apologies for bothering you, but could you tell me how could I use the library with the PR? Thanks.

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

Successfully merging a pull request may close this issue.

3 participants