System.Drawing.Common Alternatives (.NET 7 & Non-Windows)

Starting with .NET 6, Microsoft has stopped supporting System.Drawing.Common on Linux and macOS. This library will now only work on Windows. For more details, refer to the official documentation.

Workarounds to Avoid "System.Drawing.Common is not supported on this platform" Error

.NET 6

On non-Windows operating systems, a TypeInitializationException is thrown with a PlatformNotSupportedException as the inner exception. The platform analyzer emits compile-time warnings for non-Windows platforms. The following runtime exception is thrown unless you set a configuration option:

System.TypeInitializationException : The type initializer for 'Gdip' threw an exception.

    ---- System.PlatformNotSupportedException : System.Drawing.Common is not supported on non-Windows platforms.

Temporary work-around in .NET 6:

Enable support for non-Windows platforms by setting the System.Drawing.EnableUnixSupport runtime configuration switch to true in the runtimeconfig.json file:

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

Additionally, add the following line at the beginning of your code to enable the configuration programmatically:

// Enable System.Drawing.Common support on non-Windows platforms in .NET 6
System.AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true);
// Enable System.Drawing.Common support on non-Windows platforms in .NET 6
System.AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true);
' Enable System.Drawing.Common support on non-Windows platforms in .NET 6
System.AppContext.SetSwitch("System.Drawing.EnableUnixSupport", True)
$vbLabelText   $csharpLabel

.NET 7 and above

Starting from .NET 7, Microsoft has completely removed support for System.Drawing.Common on Linux and macOS, including the previously available workaround.

Iron Software has released an open-source replacement for System.Drawing.Common, called IronSoftware.Drawing.

To learn more, visit the official documentation.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More
Ready to Get Started?
Nuget Downloads 16,315,602 | Version: 2025.11 just released