Base solution for your next web application
Open Closed

System.Drawing Compability on non-Windows platforms #10936


User avatar
0
MainTechAS created

Hi, I'm currently testing installation of ASPNetZero version 11.1 (Type: <span class="colour" style="color: rgb(0, 0, 0);">ASP.NET CORE & Angular, Framework: </span>.NET6, version 11.1) on Linux and noticed the build warnings "This call site is reachable on all platforms. 'Bitmap' is only supported on: 'windows'".

Searching issues regarding this on the ASPNetZero support site I found Not able to change the profile picture after deploying in Azure App Service Linux from a couple of years back.

And the remedy back then was utilizing libgdiplus for supporting the System.Drawing.Common Nuget package on Linux.

Regarding the release of .NET6 an the usage of System.Drawing on non-Windows platforms, Microsoft states the following:

System.Drawing compability ... The System.Drawing.Common NuGet package is now attributed as a Windows-specific library. The platform analyzer emits warning at compile time when compiling for non-Windows operating systems. On non-Windows operating systems, unless you set a runtime configuration switch, a TypeInitializationException exception is thrown with PlatformNotSupportedException as the inner exception. ... Since the inclusion of the Mono cross-platform implementation, we have redirected numerous issues to libgdiplus that never got fixed. In comparison, other external dependencies we have taken, such as icu or openssl, are high-quality libraries. It's not viable to get libgdiplus to the point where its feature set and quality is on par with the rest of the .NET stack. ...

Microsoft list these alternatives for recommended action To use these APIs for cross-platform apps, migrate to one of the following libraries:

  • ImageSharp
  • SkiaSharp
  • Microsoft.Maui.Graphics

Even though System.Drawing.EnableUnixSupport might be set to true, this will be deprecated in .NET7

So, in the near future, do we see ASPNetZero moving away from System.Drawing to a different library for GDI functionality, such as Microsoft.Maui.Graphics ?

Thanks.


2 Answer(s)