.NET, System.Drawing.Common is not supported on this platform

Trying to develop on a .NET 6 project – experience issues with the unsupported System.Drawing.Common module. (Breaking change: System.Drawing.Common only supported on Windows - .NET | Microsoft Docs)

steps:

  1. Install libgdiplus: sudo pacman -S libgdiplus
  2. Build project: sudo dotnet run
---------------------
SDK Version: 6.0.102

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Unhandled exception. System.PlatformNotSupportedException: System.Drawing.Common is not supported on this platform.
   at System.Drawing.Image..ctor()
   at System.Drawing.Bitmap..ctor(String filename)
   at ...```

What is your question / problem?

I want to find a solution obviously. It works on Ubuntu, and is only officially supported on Windows.

Did you read the page that you have linked above?

The solution is mentioned there.

Yes, I have tried this. Sorry for not making this clear. I believe that an old version of GDI+ which is avaliable on AUR is the culprit.

Just tried and it works fine for me (I’m on vanilla arch, but that should not make a difference).

So you did create a runtimeconfig.template.json file with this content into your project folder?

{
   "configProperties": {
      "System.Drawing.EnableUnixSupport": true
   }
}

However, as stated in the article, you better migrate your project to another library instead…

Yes, but maybe I did it incorrectly? Could you .zip the project you are using so that I could inspect the structure?

1 Like

I am still getting the same error running your file :confused:

Hello, World!
Unhandled exception. System.PlatformNotSupportedException: System.Drawing.Common is not supported on this platform.
   at System.Drawing.Image..ctor()
   at System.Drawing.Bitmap..ctor(String filename)
   at Program.<Main>$(String[] args) in /home/$user/Desktop/test/Program.cs:line 6