You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
System.Drawing.Common is not supported on non-Windows platforms #80148
System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See https://aka.ms/systemdrawingnonwindows for more information.
at System.Drawing.LibraryResolver.EnsureRegistered() in System.Drawing.Common.dll:token 0x600058c+0x11
at System.Drawing.SafeNativeMethods.Gdip.PlatformInitialize() in System.Drawing.Common.dll:token 0x6000b00+0x0
at System.Drawing.SafeNativeMethods.Gdip..cctor() in System.Drawing.Common.dll:token 0x6000af8+0x2b
The exception message is correct: System.Drawing.Common is no longer supported on .Net 6 on Linux and macOS. For more information, see this document and dotnet/docs#25257.
As that document states, if you want to continue using it on .Net 6, you can provide a runtime config switch named System.Drawing.EnableUnixSupport set to true. But even this will not work starting with .Net 7.
As for the aka.ms link, I'm not sure. Maybe it will be set up once this breaking change is properly documented (i.e. when dotnet/docs#25367 is merged).
What is the solution for this for developers?
I have a web server application running on Linux and I need to know what replaces System.Drawing for .NET 6 and later. I read in the documentation that
So now developers will use multiple libraries and .NET will have no standard image manipulation API at all?
Which one of these is the right one? For which one Microsoft can guarantee support for the next years? What are we supposed to do when these random package authors change license or drop support?
So now when people will want to learn .NET image manipulation, there will be package-specific tutorials?
MAUI image API support might not be dropped but instead, it is a UI library so depending on MAUI on an ASP.NET server application which does not relate to MAUI in any way is ridiculous.
What is the 1 and only suggested solution which will be supported by Microsoft just as .NET 6 is (LTS) etc.?
What is the suggested solution for Blazor WebAssembly projects needing to resize image before uploading to server? MAUI graphics API?
@mattleibow can you confirm that SkiaSharp is fully supported by Microsoft?
Also, I have generally thought of SkiaSharp as client focused, and something like ImageSharp better for servers. Is it reasonable to use SkiaSharp on the server side? I know that unlike ImageSharp, it has some native dependencies.
Unhandled exception. System.PlatformNotSupportedException: System.Drawing.Common is not supported on this platform.
at System.Drawing.SystemFonts.get_DefaultFont()
the settings are from myapplication.runtimeconfig.json under bin/Debug/net6.0-windows of the project root. I am trying to run the application from the project root using dotnet run. Thanks for your help.
Unhandled exception. System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
---> System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See https://aka.ms/systemdrawingnonwindows for more information.
at System.Drawing.LibraryResolver.EnsureRegistered()
at System.Drawing.SafeNativeMethods.Gdip.PlatformInitialize()
at System.Drawing.SafeNativeMethods.Gdip..cctor()
--- End of inner exception stack trace ---
at System.Drawing.SafeNativeMethods.Gdip.GdipGetGenericFontFamilySansSerif(IntPtr& fontfamily)
at System.Drawing.FontFamily.GetGdipGenericSansSerif()
at System.Drawing.FontFamily.get_GenericSansSerif()
at System.Drawing.Font.CreateFont(String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte charSet, Boolean isVertical)
at System.Drawing.Font..ctor(String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)
at System.Drawing.Font..ctor(String familyName, Single emSize, String systemName)
at System.Drawing.SystemFonts.get_DefaultFont()
made some changes and that error is fixed but I get a new one now:
Unhandled exception. System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'libgdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibgdiplus, 0x0001): tried: 'liblibgdiplus' (no such file), '/System/Volumes/Preboot/Cryptexes/OSliblibgdiplus' (no such file), '/usr/lib/liblibgdiplus' (no such file, not in dyld cache), 'liblibgdiplus' (no such file), '/usr/local/lib/liblibgdiplus' (no such file), '/usr/lib/liblibgdiplus' (no such file, not in dyld cache)
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip..cctor()
In Unix systems you can do it by running sudo apt-get install libgdiplus or whatever is the package manager for that OS.
on mac systems you need to run brew install mono-libgddiplus
Note that using 6.0.0 means that you'd be out of support so the recommended guidelines from the .NET team is to move out of depending on System.Drawing.Common for non windows.
Thanks all for the help. re: do you have to use System.Drawing? to answer literally, its a loaded question. One can always port the code to another library. In fact, I already did it for one of my GDI+ apps as I wanted to learn Swift but to my surprise the C# code runs much faster than Swift!
Also what I understand when someone says the library is out of support is that no one is fixing bugs and issues but anyone is welcome to use it as-is and it will continue to be available and downloadable from the internet. is that correct?
Also what I understand when someone says the library is out of support is that no one is fixing bugs and issues but anyone is welcome to use it as-is and it will continue to be available and downloadable from the internet. is that correct?
System.Drawing is not going anywhere, but the code inside it that uses libgdiplus has been removed, which means that it will only work on Windows now.
.NET 6 will go out of support in due course, although you'll still be able to download it if you don't mind being out of support.
In short, I recommend you don't write code against System.Drawing unless it's only intended to run on Windows. The only exception might be if it's just a temporary thing, in which case you can use .NET 6. But generally you should pick another library to do this stuff unless you're Windows only.
Reading it all I came to the conclusion that I learned not the right programming language. It was necessary to learn Java 10 years ago when C# finished with such valuable problems. Microsoft is a great company but it is not able to make support graphics basics for three OS. I will keep silent about cross-platformed desktop GUI, they are missing. Miguel De Icaza come back. If you advise migrating to MAUI or Skia, maybe will you write a wrapper for it inside Linux System.Drawing implementation?
ghost locked as resolved and limited conversation to collaborators on Feb 6, 2023
Activity
svick commentedon Aug 14, 2021
The exception message is correct: System.Drawing.Common is no longer supported on .Net 6 on Linux and macOS. For more information, see this document and dotnet/docs#25257.
As that document states, if you want to continue using it on .Net 6, you can provide a runtime config switch named
System.Drawing.EnableUnixSupportset totrue. But even this will not work starting with .Net 7.As for the aka.ms link, I'm not sure. Maybe it will be set up once this breaking change is properly documented (i.e. when dotnet/docs#25367 is merged).
mairaw commentedon Aug 14, 2021
It seems @svick has answered your question, so I’m closing this issue. Let me know if I missed anything.
mairaw commentedon Aug 14, 2021
Reopening since the link goes to our internal tool somehow.
Tagging @ericstj @danmoseley @terrajobst @safern who seem to own that link.
safern commentedon Aug 14, 2021
I'll work with @gewarren to post the doc ASAP on Monday and point the url to the doc.
gewarren commentedon Aug 16, 2021
@safern Here is the PR; it's ready for review: dotnet/docs#25367
safern commentedon Aug 16, 2021
https://aka.ms/systemdrawingnonwindows should now resolve to the published docs. Thanks for the report.
janseris commentedon Mar 16, 2022
What is the solution for this for developers?
I have a web server application running on Linux and I need to know what replaces System.Drawing for .NET 6 and later. I read in the documentation that
So now developers will use multiple libraries and .NET will have no standard image manipulation API at all?
Which one of these is the right one? For which one Microsoft can guarantee support for the next years? What are we supposed to do when these random package authors change license or drop support?
So now when people will want to learn .NET image manipulation, there will be package-specific tutorials?
MAUI image API support might not be dropped but instead, it is a UI library so depending on MAUI on an ASP.NET server application which does not relate to MAUI in any way is ridiculous.
What is the 1 and only suggested solution which will be supported by Microsoft just as .NET 6 is (LTS) etc.?
What is the suggested solution for Blazor WebAssembly projects needing to resize image before uploading to server? MAUI graphics API?
Thanks
danmoseley commentedon Mar 16, 2022
@mattleibow can you confirm that SkiaSharp is fully supported by Microsoft?
Also, I have generally thought of SkiaSharp as client focused, and something like ImageSharp better for servers. Is it reasonable to use SkiaSharp on the server side? I know that unlike ImageSharp, it has some native dependencies.
siddjain commentedon Dec 30, 2022
I am using
System.Drawing.Commonon Mac OS but with target framework 6.0 and have setbut still seeing this exception:
can anyone help please?
gewarren commentedon Dec 30, 2022
@siddjain Which file are those settings from?
siddjain commentedon Dec 30, 2022
the settings are from
myapplication.runtimeconfig.jsonunderbin/Debug/net6.0-windowsof the project root. I am trying to run the application from the project root usingdotnet run. Thanks for your help.2 remaining items
gewarren commentedon Dec 30, 2022
Looks like you're using the 7.0 version of System.Drawing.Common. Does it work if you set that to 6.0.0?
siddjain commentedon Dec 30, 2022
no it still doesn't work
siddjain commentedon Dec 30, 2022
made some changes and that error is fixed but I get a new one now:
how do I fix this one?
safern commentedon Jan 3, 2023
@siddjain for that specific error you need to make sure that
libgdiplusis installed in your OS.https://www.mono-project.com/docs/gui/libgdiplus/
In Unix systems you can do it by running
sudo apt-get install libgdiplusor whatever is the package manager for that OS.on mac systems you need to run
brew install mono-libgddiplusNote that using 6.0.0 means that you'd be out of support so the recommended guidelines from the .NET team is to move out of depending on System.Drawing.Common for non windows.
danmoseley commentedon Jan 3, 2023
@mattleibow just checking you saw my question above as it would be good to know the answer.
danmoseley commentedon Jan 3, 2023
@siddjain do you have to use System.Drawing? As mentioned, it is out of support now.
siddjain commentedon Jan 4, 2023
Thanks all for the help. re: do you have to use System.Drawing? to answer literally, its a loaded question. One can always port the code to another library. In fact, I already did it for one of my GDI+ apps as I wanted to learn Swift but to my surprise the C# code runs much faster than Swift!
Also what I understand when someone says the library is out of support is that no one is fixing bugs and issues but anyone is welcome to use it as-is and it will continue to be available and downloadable from the internet. is that correct?
danmoseley commentedon Jan 4, 2023
System.Drawing is not going anywhere, but the code inside it that uses libgdiplus has been removed, which means that it will only work on Windows now.
.NET 6 will go out of support in due course, although you'll still be able to download it if you don't mind being out of support.
In short, I recommend you don't write code against System.Drawing unless it's only intended to run on Windows. The only exception might be if it's just a temporary thing, in which case you can use .NET 6. But generally you should pick another library to do this stuff unless you're Windows only.
siddjain commentedon Jan 4, 2023
Thanks Dan for the clarification!
janseris commentedon Jan 4, 2023
@siddjain
This part is not magically for free you know especially with large codebase with little automatic tests
siddjain commentedon Jan 4, 2023
Rombersoft commentedon Jan 7, 2023
Reading it all I came to the conclusion that I learned not the right programming language. It was necessary to learn Java 10 years ago when C# finished with such valuable problems. Microsoft is a great company but it is not able to make support graphics basics for three OS. I will keep silent about cross-platformed desktop GUI, they are missing. Miguel De Icaza come back. If you advise migrating to MAUI or Skia, maybe will you write a wrapper for it inside Linux System.Drawing implementation?