Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The type initializer for 'Gdip' threw an exception. #389

Open
SpringHgui opened this issue Feb 18, 2022 · 5 comments
Open

The type initializer for 'Gdip' threw an exception. #389

SpringHgui opened this issue Feb 18, 2022 · 5 comments

Comments

@SpringHgui
Copy link

SpringHgui commented Feb 18, 2022

Type of issue

[ x] Bug
[ ] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement

Behavior

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.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, Int32 format, IntPtr scan0, IntPtr& bitmap)

https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only

@jtammaro
Copy link

jtammaro commented Mar 4, 2022

+1

@uziruk
Copy link

uziruk commented Mar 9, 2022

+1, I believe this has to do with microsoft droping system.drawing support on non windows oses.
Maybe it could be replaced with imagesharp?

@JoseAFerrer
Copy link

+1, but I thought it had something to do with my system being an Apple M1. I'll keep working on it and let you know if I manage to solve it.

@namespacedevbox
Copy link

namespacedevbox commented Aug 9, 2022

temporary solution, create runtimeconfig.template.json

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

@tkggusraqk
Copy link

tkggusraqk commented Jan 4, 2023

The aarch64 schema test is invalid

"error":{"ClassName":"System.TypeInitializationException","Message":"The type initializer for 'Gdip' threw an exception.","Data":null,"InnerException":{"ClassName":"System.PlatformNotSupportedException","Message":"System.Drawing.Common is not supported on non-Windows platforms. See https://aka.ms/systemdrawingnonwindows for more information.","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":" at System.Drawing.LibraryResolver.EnsureRegistered()\n at System.Drawing.SafeNativeMethods.Gdip.PlatformInitialize()\n at System.Drawing.SafeNativeMethods.Gdip..cctor()","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":null,"HResult":-2146233031,"Source":"System.Drawing.Common","WatsonBuckets":null},"HelpURL":null,"StackTraceString":" at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, Int32 format, IntPtr scan0, IntPtr& bitmap)\n at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)\n at QRCoder.QRCode.GetGraphic(Int32 pixelsPerModule, Color darkColor, Color lightColor, Boolean drawQuietZones)\n at Zwt.MvcAdmin.Controllers.HomeController.CreateQR(String baseUrl, String content)\n

error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants