-
Notifications
You must be signed in to change notification settings - Fork 1.2k
System.TypeInitializationException: 'The type initializer for 'Gdip' threw an exception.' #83
Comments
Just confirmed...this works fine when using Beta 1 but Beta 2 breaks. Just noticed this comment against sampleapp.core "Beta 2. Replaced CoreCompat.System.Drawing.v2 with System.Drawing.Common" |
Still a problem with 4.5.1 and preview 3 of System.Drawing.Common? |
I have the same problem for our setup at work - .NET Core 2.0.8 with Docker in a clustered environment. Have commented out AutoFit for now. |
About
|
I had this same issue and also installing libc6-dev solved it.
|
Yes, unfortunately you need to install A fix for this in .NET Core depends on https://github.com/dotnet/corefx/issues/17135 being implemented. If you're hitting this issue and would like to see it solved - it would help if you can upvote that issue in the .NET Core repository. |
From Docker:
|
Any idea how to resolve this problem for Centos? |
Still getting: EDIT: FIXED BY MOVING / PUTTING
|
Do you need to restart after |
What is the possibility of removing the code relayed upon libgdiplus. In my scenario, I have encountered with an error when I try to add image to the sheet. As far as I can see in the code the code can be replaceable by any image manipulation library like ImageSharp. *https://github.com/SixLabors/ImageSharp |
The problem continues even if I install |
Note that, the package names are little bit defferent with those on Ubuntu. |
Yes, worked this command lines;
|
I'm working with an Azure app service on Linux and I get this error as well. |
Here's what I recommend:
If you do this, you should not need the |
I don't know if I can install a library on an Azure Web App. Is it something that should be part of the azure devOps deployment? I'm quite new with Azure and Linux ^^ |
Sorry, don't know about App Service. |
I'm having the same problem with the version 4.5.3.2 of Epplus , that uses Sytem.Drawing.Commom 4.6.0 |
@felipe-rodrigues Are you on .NET Core 3.0? |
No I'm using 2.2 |
This is fixed in .NET Core 3.0 but not 2.2. If you're on 2.2, you'll need to install libc6-dev, glibc6-devel or the equivalent package for your distro which contains libdl.so. .NET Core 2.2 goes out of support this month, so that's another incentive to upgrade 😄 . |
I'll change , but for a while I got doing what you said.
|
Does anyone know how to fix this if your using the alpine image? (3.1-alphine) Managed to get libgdiplus installed but its not hooking up correctly i think. RUN apk add libgdiplus --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted |
@jonny64bit What .NET Core version and System.Drawing.Common version are you using? On .NET Core 3.x and 4.6.0, it should pick up libgdiplus.so.0 just fine. What does PS: I don't think there is any scenario in which |
@qmfrederik using:
ldd /usr/lib/libgdiplus.so.0 gives me /lib/ld-musl-x86_64.so.1 (0x7f59626a7000) |
That's odd; I don't see anything that immediately catches my eye. Could you try running your program with
It should get you a more precise idea of which library fails to load. |
@qmfrederik i have to admit i struggled to get any output out of doing LD_DEBUG=libs. Thanks for your help. i have managed to fix my issue by doing:
|
I am running an application using EPPlus 4.5.0.1-beta under docker with microsoft/aspnetcore:2.0.4. My docker file includes the following to ensure GDI+ is installed:
RUN apt-get update
RUN apt-get install -y libgdiplus
In this snippet of code:
The "AutoFit" method is throwing the following:
An unhandled exception has occurred while executing the request
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libdl': The specified module or one of its dependencies could not be found.
(Exception from HRESULT: 0x8007007E)
at Interop.Libdl.dlopen(String fileName, Int32 flag)
at System.Drawing.SafeNativeMethods.Gdip.LoadNativeLibrary()
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 OfficeOpenXml.ExcelRangeBase.AutoFitColumns(Double MinimumWidth, Double MaximumWidth)
at MyApp.Common.ReportHelper.ExtractDataFromRedshift(GetReportRequest request) in C:\Development\MyApp\Common\ReportHelper.cs:line 93
at MyApp.Controllers.EtlController.GetReport(GetReportRequest request) in C:\Development\MyApp\Controllers\EtlController.cs:line 40
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.d__7.MoveNext()
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware:Error: An unhandled exception has occurred while executing the request
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libdl': The specified module or one of its dependencies could not be found.
(Exception from HRESULT: 0x8007007E)
at Interop.Libdl.dlopen(String fileName, Int32 flag)
at System.Drawing.SafeNativeMethods.Gdip.LoadNativeLibrary()
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 OfficeOpenXml.ExcelRangeBase.AutoFitColumns(Double MinimumWidth, Double MaximumWidth)
at MyApp.Common.ReportHelper.ExtractDataFromRedshift(GetReportRequest request) in C:\Development\MyApp\Common\ReportHelper.cs:line 93
at MyApp.Controllers.EtlController.GetReport(GetReportRequest request) in C:\Development\MyApp\Controllers\EtlController.cs:line 40
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.d__7.MoveNext()
This was working perfectly yesterday and works fine when I am running it under dotnet under windows.
The text was updated successfully, but these errors were encountered: