C#C
C#3y ago
13 replies
2fur

❔ Trying to use System.drawing.common 6.0.0 on Linux. Why it doesnt work?

hello, I'm using System.Drawing.Common version 6.0.0 because I read that it should support linux. I changed the runtimeconfig.json as recommended on the microsoft website, but it still doesn't work.

I tried this solution: learn.microsoft.com/pl-pl/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only

And this is what my json looks like:
{
   "runtimeOptions": {
     "tfm": "net6.0",
     "framework": {
       "name": "Microsoft.NETCore.App",
       "version": "6.0.0",
       "configProperties": {
         "System.Drawing.EnableUnixSupport": true
       }
     }
   }
}


The error I get:
The type initializer for 'Gdip' threw an exception. System.Func'1[System.Exception] at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(Int32 width, Int32 height, int32 stride , Int32 format, IntPtr scan0, IntPtr& bitmap)

 at ProtogenTheBot.commands.com_2.punishment(CommandContext ctx, String options) in D:\Vs projects\ProtogenTheBot\commands\com_2.cs:line 236 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()


Please help me solve the problem.
Thank you in advance
Was this page helpful?