C
C#16mo ago
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
}
}
}
}
{
"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
5 Replies
Jimmacle
Jimmacle16mo ago
like the page says, it's not supported so if it doesn't work you're out of luck you should switch to one of the other libraries it lists but your runtimeconfig has the options in the wrong place in the file
2fur
2furOP16mo ago
please tell me what it should look like correctly. It can solve my problem in some way i should place configPropeties below framework? something like that?
{
"runtimeOptions": {
"tfm": "net6.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
},
"configProperties": {
"System.Drawing.EnableUnixSupport": true
}
}
}
{
"runtimeOptions": {
"tfm": "net6.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
},
"configProperties": {
"System.Drawing.EnableUnixSupport": true
}
}
}
Jimmacle
Jimmacle16mo ago
yes, that's how the page says to do it
reflectronic
reflectronic16mo ago
your configProperties is in the wrong place look at the example in the documentation. it is outside of the runtimeOptions element, not inside of it https://learn.microsoft.com/en-us/dotnet/core/runtime-config/#example-appnameruntimeconfigjson-file oh, i see i should have scrolled down
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server